Message 1 of 6
Changing Dynamic Block Property Values with VBA
Not applicable
01-28-2008
07:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have found several threads concerning manipulation of Dynamic blocks using VBA. Most of them tend to have
a variation of the code posted below, which appears to
work great if you are trying to change the visibility property.
Private Sub ScanBlks()
Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "cirtagleader" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"
End If
Next i
End If
End If
End If
Next
End Sub
However if I replace the following code:
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"
With
If dybprop(i).PropertyName = "Distance1" Then
dybprop(i).Value = 36
I get
"Run-time error '438':
Object doesn't support this property or method"
Any help would be more than appreciated,
Thanks in advance,
Chris
a variation of the code posted below, which appears to
work great if you are trying to change the visibility property.
Private Sub ScanBlks()
Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "cirtagleader" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"
End If
Next i
End If
End If
End If
Next
End Sub
However if I replace the following code:
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"
With
If dybprop(i).PropertyName = "Distance1" Then
dybprop(i).Value = 36
I get
"Run-time error '438':
Object doesn't support this property or method"
Any help would be more than appreciated,
Thanks in advance,
Chris