Jump to content

ID of Block Reference


Clemp

Recommended Posts

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 :

 

329075Sanstitre.png

 

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 ? :)

Link to comment
Share on other sites

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 :

 

329075Sanstitre.png

 

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

Link to comment
Share on other sites

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

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...