P. 1
81959924 AutoCAD VBA Programming Tools and Techniques

81959924 AutoCAD VBA Programming Tools and Techniques

|Views: 280|Likes:
Published by xuanhuynh

More info:

Published by: xuanhuynh on Nov 02, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Page 147

The following code example shows how to apply the transformation matrix from a UCS object. The example uses a
coordinate system previously created and saved with the name ''MY_UCS". A circle is defined in the WCS, then rotated
relative to the stored UCS. The center point of the circle is reset after the transformation so that the selected point
remains the center point of the object. The transformation will most likely change the circle object center point value
thus making this operation a requirement.

' Current UCS is expected to the World Coordinate System (WCS)
Dim UCS_Mine As AcadUCS 'get UCS info from table
Set UCS_Mine = ThisDrawing.UserCoordinateSystems.Item("MY_UCS")
Dim p1 As Variant 'user input of a point
p1 = ThisDrawing.Utility.GetPoint(, "Center point")
Dim Obj As AcadCircle 'draw the circle, radius is one
Set Obj = ThisDrawing.ModelSpace.AddCircle(p1, 1#)
Dim TrnsMtx As Variant 'get the transformation matrix
TrnsMtx = UCS_Mine.GetUCSMatrix
Obj.TransformBy (TrnsMtx) 'apply transformation
Obj.Center = p1 'reset center point to original
Obj.Update 'regenerate the object on the screen

If you modify an existing UCS, you must update the document object after all modifications are completed. To update
the current UCS, simply set the active UCS to be the UCS name once again. Any changes made to the UCS object will
now be applied.

The Views Collection

The various 3D views that have been saved with names using the VIEW command in a drawing are stored in the views
collection. This collection consists only of view objects, the properties that define the view. To create a new view, use
the Add( ) method in the Views collection. The views

< previous page


next page >

< previous page


next page >

Page 148

collection is also where views are referenced by name or index. To remove a named view from the collection, the Delete( ) method is used.
Like most other AutoCAD special object collections, the Delete( ) method is found in the view object and not in the collection.

The following table lists the primary properties used to manipulate view objects.


What it is


Where the view originates. This can be thought of as the location of the observer.


Vector describing the direction of the view.


Height (Y) of the view in the drawing.


Name of the view.


Target point. This can be thought of as the location the observer is looking toward.


Width (X) of the view in the drawing.

The View Ports Collection

The view ports collection is where named view ports are stored for the drawing. The user creates a named view port with the VPORTS
command while in model space. Programmers can create named view ports by adding new names to the view ports collection with the Add( )
method. It is important to note at this time that view ports, as used in this context, are not the same as paper space view ports, and they are not
the same as named views.

A view port is a rectangular area that defines a region of the display where a portion or all of the drawing can be shown. View ports are not the
same as views. A view simply describes how the observer is oriented relative to the objects in either model or paper space. A view port not
only describes that orientation; it also describes the area or region where the view is displayed relative to the display device. Paper space view

< previous page


next page >

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->