Jump to content

VBA Get Properties of Entity


plantdesign

Recommended Posts

Hi!

 

I am trying to loop through all objects in a drawing and read their properties. I have found code to do this if the object is a block but if the object is just an "entity" (non block geometry) then i can still read some of the properties but I need to find a particular one. It's the one that is called "Group" when you list the object. I can read the properties with the red arrows, but NOT the Group property (blue)

 

attachment.php?attachmentid=1446&d=1305752150

 

My weak VBA looks like this...

 

Code:

Private Sub Test()

Dim entity As Object

Dim myBlock As AutoCAD.AcadBlockReference

Dim vatts As Variant

 

Set ss = ThisDrawing.SelectionSets.Add("NewS856")

ss.SelectOnScreen

For Each entity In ss

array1 = entity.GetAttributes

For j = 0 To UBound(array1)

entity.Layer = "Hello"

Next

Next

 

End Sub

I don't know if you can even use GetAttributes with 'entity' or not. If anyone has any input here on how to do this properly I sure would appreciate it.

 

Thanks!

Link to comment
Share on other sites

You need to just get all entities and then check what is it, line, pline, block etc then call a sub to do some thing with it. Instead of entity.getattributes need a get obj type

 

Found this

 

 

Dim SS As AcadSelectionSet
Dim val As String
Dim acdLINE As AcadLine

On Error Resume Next
Set SS = ThisDrawing.SelectionSets.Add("MYSS")
SS.Select acSelectionSetAll

val = "AcDbPoint" 

For i = 0 To SS.Count
   Set objENT = SS(i)
   If objENT.ObjectName = val Then do something

 

You need to know correct syntax for AcDbline etc

Link to comment
Share on other sites

Thanks, BIGAL. I am able to loop through all the objects with your code.

 

I am going to be migrating this entire project to .net so I will be making a new post for that with a more detailed explanation of what I am trying to get at.

 

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...