Problem Editing Dynamic Block Properties

Problem Editing Dynamic Block Properties

Anonymous
Not applicable
1,398 Views
1 Reply
Message 1 of 2

Problem Editing Dynamic Block Properties

Anonymous
Not applicable

It seems that I just don't have the best luck with my blocks. I have a function that is used to insert dynamic blocks into Modelspace and set some of its dynamic attributes according to specifications made in an Excel spreadsheet I'm reading from. I don't know what is causing this, but I am unable to change the values for the dynamic properties. I get the properties and read the values, but when I try to write the value, the routine exits without error. Here is the code to insert gridlines. Am I missing something simple?

Sub InsertGridline(ByRef insertionPnt As Variant, ByVal distance As String, ByVal totalDist As String, ByVal bubbleName As String)
Dim newBlock As AcadBlockReference

If vertical Then
insertionPnt(0) = insertionPnt(0) + CalculateDistance(distance)
blockPath = "T:\Engineering\01-FIXED\50- New Template\TITLE BLOCKS\DYNAMIC BLOCKS\V_GRIDLINE.dwg"
Else
insertionPnt(1) = insertionPnt(1) + CalculateDistance(distance)
blockPath = "T:\Engineering\01-FIXED\50- New Template\TITLE BLOCKS\DYNAMIC BLOCKS\H_GRIDLINE.dwg"
End If
'Insert the block Set newBlock = ThisDrawing.ModelSpace.insertBlock(insertionPnt, blockPath, 1#, 1#, 1#, 0)

Dim attList As Variant
Dim att As AcadAttributeReference attList = newBlock.GetAttributes For i = 0 To UBound(attList) Set att = attList(i) att.TextString = bubbleName Next Dim name As String
Dim DynamicAttList As Variant Dim prop As AcadDynamicBlockReferenceProperty DynamicAttList = newBlock.GetDynamicBlockProperties For i = 0 To UBound(DynamicAttList) Set prop = DynamicAttList(i) name = prop.PropertyName If name = "GL Length" Then prop.Value = totalDist
' "DynamicAttList(i).Value = totalDist" does not work either ElseIf name Like "*Perp*" Then prop.Value = 0 ElseIf name Like "*Para*" Then prop.Value = 0 ElseIf name Like "*Flip*" Then prop.Value = "Not Flipped" End If Next End Sub

 

0 Likes
Accepted solutions (1)
1,399 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Okay, so I think I am just an idiot... After doing some work with the Error object, I figured out that it wasn't accepting the types I was passing to my "prop.Value = ..." statement. I had tried using the CVar() method, but apparently, for this attribute, it must strictly be a double. I was able to type cast with CDbl() and now it works just fine... 

0 Likes