| Edit Dynamic Block Settings |
|
|
|
| Tutorials | |||
|
The Insert Dynamic Block Example showed how to insert a Dynamic Block. It could be possible that Dynamic blocks are already in the drawing. With the following function its possible to change the parameters of a block without.
Show/Hidden vbnet code
Function editblock(ByVal Parametername, ByVal Newvalue, ByVal Blockname As String)
Dim ent As AcadEntity
Dim oBkRef As IAcadBlockReference
Dim oDynProp As AcadDynamicBlockReferenceProperty
Dim v As Variant
Dim I As Long
For Each ent In ThisDrawing.ModelSpace
If ent.ObjectName = "AcDbBlockReference" Then
Set oBkRef = ent
If oBkRef.IsDynamicBlock = True Then 'Check if it is a dynamic block
v = oBkRef.GetDynamicBlockProperties 'Get all Dynamic attributes
If oBkRef.EffectiveName = Blockname Then
For I = LBound(v) To UBound(v)
Set oDynProp = v(I)
If Not IsArray(oDynProp.Value) Then 'Not an array
If oDynProp.PropertyName = Parametername Then
Str (oDynProp.Value)
oDynProp.Value = Newvalue 'Set the new value
End If
End If
Next
End If
End If
End If
Next ent
End FunctionCall this function using: If we take the block from the Insert Dynamic Block Example then we would use: So all blocks with the name 'Block' are now 200 mm Wide and 200mm Long
|



