Using VBA to window crossing to erase objects.

Using VBA to window crossing to erase objects.

muckmailer
Collaborator Collaborator
946 Views
2 Replies
Message 1 of 3

Using VBA to window crossing to erase objects.

muckmailer
Collaborator
Collaborator

Is there a routine that allows a user to pick 2 points to erase objects crossing the window
in VBA for AutoCAD 2010?
Thank you,

0 Likes
947 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

Do you want the code of a routine that is ready to use, or do you want to know/learn how to do that in code?

For the former, you can search Acad's VBA document and its sample code, or search this forum, the Internet.

For the latter, you can look into AcadSelection.Select()/SelectOnScreen() method. If you happen to know what Object Browser is in VBA IDE, highlight these methods in Object Browser and click "?" button, ACad VBA document will show you the details about them and sample code of how to use them. Once you get an instance of AcadSelectionSet and selected one or more AcadEntity in it, simply loop through it to call AcadEntity.Delete() to erase objects from drawing.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable
Dim FilterType(0) As Integer Dim FilterData(0) As Variant 'FilterType(0) = 0 'Indicates filter refers to an object type 'FilterData(0) = "Circle" 'Indicates the object type is "Circle" 'Specify a single selection criterion for a selection set '0 Object Type (String) Such as “Line,” “Circle,” “Arc,” and so forth. '2 Object Name (String) The table (given) name of a named object. '8 Layer Name (String) Such as “Layer 0.” '60 Object Visibility (Integer) Use 0 = visible, 1 = invisible. '62 Color Number (Integer) Numeric index values ranging from 0 to 256. ' Zero indicates BYBLOCK. 256 indicates BYLAYER. A negative value indicates that the layer is turned off. ' 67 Model/paper space indicator (Integer) Use 0 or omitted = model space, 1 = paper space. 'For a complete list of DXF group codes, see Group Code Value Types in the DXF Reference. 'http://www.autodesk.com/techpubs/autocad/acad2000/dxf/group_codes_in_numerical_order_dxf_01.htm 'The filter arguments are declared as arrays. The filter type is declared as an integer and the filter value as a variant. Each filter type must be paired with a filter value. Dim sstext As AcadSelectionSet Set sstext = ThisDrawing.SelectionSets.Add("SS2") 'FilterType(0) = 8 FilterType(0) = 8 FilterData(0) = "*BASI" sstext.Select acSelectionSetAll, , , FilterType, FilterData or Dim PT1(0 To 2) As Double Dim PT2(0 To 2) As Double sstext.Select acSelectionSetCrossing,PT1 ,PT2 , FilterType, FilterData if you want select more object inside the crossing selection point PT1 and PT2 I hope this can helps you as starting point to develop your code.
0 Likes