plantdesign Posted May 18, 2011 Share Posted May 18, 2011 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) 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! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 24, 2011 Share Posted May 24, 2011 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 Quote Link to comment Share on other sites More sharing options...
plantdesign Posted May 24, 2011 Author Share Posted May 24, 2011 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.