Jump to content

VBA Create attblocks


ollie

Recommended Posts

Hey folks

 

i wrote my first cva autocad script today and was wondering if you's could pass on any advice:

 

the script creates new attdefs that are replicas of old block attributes:

 

Sub Block_edit()
Dim objCount As Integer
Dim mspaceObj As AcadObject
Dim att As AcadAttributeReference
Dim block As AcadBlockReference
Dim i As Integer
objCount = ActiveDocument.ModelSpace.Count

For i = 0 To objCount - 1
   Set mspaceObj = ThisDrawing.ModelSpace.Item(i)
   If mspaceObj.ObjectName = "AcDbBlockReference" Then
       Set block = mspaceObj
       retval = block.GetAttributes()
        For Each c In retval
           Set att = c
           Set new_att = ThisDrawing.ModelSpace.AddAttribute(att.Height, acAttributeModeNormal, "", att.InsertionPoint, att.TagString, att.TextString)
       Next c
   End If
Next
   
End Sub

 

It works fine but i don't know how to create a selection set or collection of these items so i can turn them into a block later on.

 

Any suggestions would be great

 

Thannks

Ollie.

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