VBA and AutoCAD objects
VBA and AutoCAD objects
(OP)
I am writing a VBA porgram in AutoCAD to modify some existing drawings. In particular the program is updating the attribute data for some block references. I have found out how to access the text data and update it once I have the block reference.
The problem is that the block references are in the ModelSpace collection which is a collection of all of the entities in the drawing. This includes text, lines etc. As I go through these entities, I need a way to determine if it is a block reference. As I go through the ModelSpace collection I reference each entity as an object. I need a way to determine if an object is of type AcadBlockReference. Does anyone have any ideas?
The problem is that the block references are in the ModelSpace collection which is a collection of all of the entities in the drawing. This includes text, lines etc. As I go through these entities, I need a way to determine if it is a block reference. As I go through the ModelSpace collection I reference each entity as an object. I need a way to determine if an object is of type AcadBlockReference. Does anyone have any ideas?





RE: VBA and AutoCAD objects
RE: VBA and AutoCAD objects
I looked up the SelectionSet object in the help, and you have to add objects to the collection first. Not very helpful in my case.
RE: VBA and AutoCAD objects
Dim sSSname as String
Dim iCode As Integer
Dim iMode As Integer
Dim iAcadCodes(0) As Integer
Dim vAcadValues(0) As Variant
Dim vFilterType As Variant
Dim vFilterData As Variant
Dim acSelSet As AcadSelectionSet
Dim acSelSets As AcadSelectionSets
'''''''''''''''''''''''''''''''''''''''
iCode = 0 'object type
iMode = 5 'acSelectionSetAll
sSSname = "SSET"
Set acSelSets = ThisDrawing.SelectionSets
For Each acSelSet In acSelSets
If acSelSet.Name = sSSname Then
ThisDrawing.SelectionSets.Item(sSSname).Delete
Exit For
End If
Next
Set acSelSet = ThisDrawing.SelectionSets.Add(sSSname)
iAcadCodes(0) = iCode 'dxf code for block name
vAcadValues(0) = "INSERT"
vFilterType = iAcadCodes
vFilterData = vAcadValues
acSelSet.Select iMode, , , vFilterType, vFilterData
"Everybody is ignorant, only on different subjects." — Will Rogers