Jump to content

Assigning Block Attributes prior to insertion


streng

Recommended Posts

Am trying to set attributes to a block prior to insertion but cannot figure out how to set attributes.

 

Have worked with .getattributes but am unsure how to set them.

 

Hope someone can help.

 

Private Sub CommandButton4_Click()
Dim Array1 As Variant
Dim varInsertionPoint As Variant
Unload Me

With ThisDrawing.Utility
varInsertionPoint = .GetPoint(, vbCr & "Pick The Insertion Point: ")
End With

'Need to assign the following prior to inserting block
Array1(0).TextString = TextBox1.Value
Array1(0).color = ComboBox2.Value
Array1(0).Layer = ComboBox1.Value
Array1(1).TextString = TextBox2.Value
Array1(1).Layer = ComboBox1.Value
Array1(2).TextString = TextBox3.Value
Array1(2).Layer = ComboBox1.Value

ThisDrawing.ModelSpace.InsertBlock varInsertionPoint, "SRD20", 1, 1, 1, 0


End Sub

Link to comment
Share on other sites

My VBA is lacking, but maybe something like:

 

Dim Insertion As Variant
Dim BlockObj As AcadBlockReference
Dim Attribs As Variant
Dim K As Integer

Set BlockObj = ThisDrawing.ModelSpace.InsertBlock(Insertion, "block", 1, 1, 1, 0)

Attribs = BlockObj.GetAttributes

For K = LBound(Attribs) to UBound(Attribs)
 Attribs(K).TextString = "Lee Mac"
Next K

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