Clemp Posted May 14, 2014 Share Posted May 14, 2014 Hello. During my intership I was asked to make a VBA code to automate some actions, but I have never used AutoCAD before so I would need some help. There are plenty of Block Reference which are devided by groups, and my objective is to select each group and make a new layer with this selection zoomed. I'v already found how to get the position of a block reference (.InsertionPoint) and now I want to get the ID of the blocks. Exemple : Here I want to get "051_015_10_1726" so I know this bloc reference is from group 10. I thought .ObjectID would do the job, but I just feel like it gives random numbers Any advice ? Quote Link to comment Share on other sites More sharing options...
neophoible Posted May 14, 2014 Share Posted May 14, 2014 Get a mod to move this to Forum for .NET, ObjectARX & VBA. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 14, 2014 Share Posted May 14, 2014 During my intership I was asked to make a VBA code to automate some actions, but I have never used AutoCAD before so I would need some help. There are plenty of Block Reference which are devided by groups, and my objective is to select each group and make a new layer with this selection zoomed. I'v already found how to get the position of a block reference (.InsertionPoint) and now I want to get the ID of the blocks. Exemple : Here I want to get "051_015_10_1726" so I know this bloc reference is from group 10. I thought .ObjectID would do the job, but I just feel like it gives random numbers Any advice ? Welcome to CADTutor. I could be mistaken, as there is no sample drawing to dig through, but it appears as though you're after the nested Attribute Object's TextString Property. Cheers Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 15, 2014 Share Posted May 15, 2014 This may be helpfull FilterDXFCode(0) = 0 FilterDXFVal(0) = "INSERT" 'FilterDXFCode(1) = 2 'FilterDXFVal(1) = "SCHEDTEXT" Set SS = ThisDrawing.SelectionSets.Add("pit1sel") SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal For Cntr = 0 To SS.Count - 1 If SS.Item(Cntr).Name = BLOCK_NAME Then attribs = SS.Item(Cntr).GetAttributes If attribs(0).TextString = pitname Then txtx1 = CStr(FormatNumber(pt1(0), 3)) TXTY1 = CStr(FormatNumber(pt1(1), 3)) attribs(1).TextString = txtx1 attribs(2).TextString = TXTY1 attribs(1).Update attribs(2).Update Quote Link to comment Share on other sites More sharing options...
Clemp Posted May 15, 2014 Author Share Posted May 15, 2014 BlockRef.GetAttributes(0).TextString This works perfectly. Thank you all ! 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.