Jump to content

attribute extraction of dynamic blocks


Huibert

Recommended Posts

I am writing a code for the insertion of a large number of dynamic blocks (up to 1000). Each of these blocks can have different dynamic block properties and attributes. My code works with an Excel file and a database where all the information is stored. The drawing can be changed and redrawn by changing the excel file.

But I want, that if the drawing is changed in AUTOCad that the excelfile can be updated aswell. All dynamic blocks are an insertion of the dynamicblock "Poer". But i don't know how to search for this name as AutoCad creates new names for inserted dynamicblocks *U6 to *U1000.

 

Question: How can I identify a blockreference if it is the insertion of dynamic block Poer?

 

Friend Sub attributeextraction()
   Dim Poer As AcadBlockReference
   Dim Ent As AcadEntity
   Dim Layout As AcadLayout
   Dim Naam As String
   Dim Blockproperties() As AcadDynamicBlockReferenceProperty
   Dim Attributen() As AcadAttributeReference
   
   For Each Layout In ThisDrawing.Layouts
       If Layout.Name = "Model" Then
       For Each Ent In Layout.block
           If TypeOf Ent Is AcadBlockReference Then
   'PROBLEM: I need to check if the Ent is the dynamic block "Poer"
               Set Poer = Ent
               For j = LBound(Attributen) To UBound(Attributen)
                   Naam = Attributen(j).TagString
                   'code to be inserted
               Next j
               Blockproperties = Poer.GetDynamicBlockProperties
               Attributen = Poer.GetAttributes
               For j = LBound(Blockproperties) To UBound(Blockproperties)
                   Naam = Blockproperties(j).PropertyName
                   'code to be inserted
               Next j
           End If
       Next
       End If
   Next
End Sub

 

In The properties list in AutoCad it states under misc>name "POER" but if I ask in the code Poer.name it gives *Uxx

Link to comment
Share on other sites

the correct code (without the name check):

 

Friend Sub attributeextraction()
   Dim Poer As AcadBlockReference
   Dim Ent As AcadEntity
   Dim Layout As AcadLayout
   Dim Naam As String
   Dim Blockproperties() As AcadDynamicBlockReferenceProperty
   Dim Attributen() As AcadAttributeReference
   
   For Each Layout In ThisDrawing.Layouts
       If Layout.Name = "Model" Then
       For Each Ent In Layout.block
           If TypeOf Ent Is AcadBlockReference Then
           
   'PROBLEM: I need to check if the Ent is the dynamic block "Poer"

               Set Poer = Ent

               MsgBox Poer.Name


               Blockproperties = Poer.GetDynamicBlockProperties
               Attributen = Poer.GetAttributes
               For j = LBound(Blockproperties) To UBound(Blockproperties)
                   Naam = Blockproperties(j).PropertyName
                   'code to be inserted
               Next j
               For j = LBound(Attributen) To UBound(Attributen)
                   Naam = Attributen(j).TagString
                   'code to be inserted
               Next j
           End If
       Next
       End If
   Next
End Sub

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