×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA and AutoCAD objects

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?

RE: VBA and AutoCAD objects

Select the AcadBlockReference in SelectionSet is best. Then cycle through SelectionSet doing your stuff.

RE: VBA and AutoCAD objects

(OP)
    I found a way to determine what an object is. There is a function call TypeName which returns the class name of the function argumnet. Using this I can only process the Block References.
    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

zimgirl is right, you need to get a selection set of only blockreferences, the following should help to start...




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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources