sean
sean

Reputation: 1502

How to manipulate the selected objects on screen in AUTOCAD using VBA?

In autocad 2008, I want to learn how to operate the screen selected objects. There is a VBA object named ThisDrawing.SelectionSets, but it is a sets of selections, not the selected objects which are selected by user. Which VBA object represents the user selected objects?

Upvotes: 0

Views: 6995

Answers (2)

mohnston
mohnston

Reputation: 757

There is also a "built-in" selection set you can use that represents the currently selected objects.

Public Sub test()
    Dim ss As AcadSelectionSet
    Set ss = ThisDrawing.ActiveSelectionSet
    MsgBox ss.Count

End Sub

Upvotes: 1

JayP
JayP

Reputation: 809

You actually need to create your own Selection Set and add it to ThisDrawing.SelectionSets.

Then when the user clicks on an entity you need to add it to the Selection Set you created.

Finally, you can then step through every entity in the Selection Set to perform some manipulation on it.

I'm sorry I can't offer VBA code as I use C# but this is the process that you need to follow. You can however get help from within AutoCAD itself by hitting F1 and then looking under:

ActiveX and VBA Developer's Guide -> Create and Edit AutoCAD Entities -> Work with Selection Sets

Upvotes: 0

Related Questions