Home AutoCad VB Edit Dynamic Block Settings
20 | 05 | 2012
This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade

Edit Dynamic Block Settings PDF Print E-mail
User Rating: / 2
PoorBest 
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
View source
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 Function

Call this function using:

Show/Hidden vbnet code

View source
 Editblock "YourParametername", newvalue, "YourBlockname" 

 If we take the block from the Insert Dynamic Block Example then we would use:

Show/Hidden vbnet code

View source
 Editblock "Xvalue", 200, "block"
 
	Editblock "Yvalue", 200, "block" 

So all blocks with the name 'Block' are now 200 mm Wide and 200mm Long

 


Attachments:
FileDescriptionFile sizeDownloads
Download this file (EditDynBlock.zip)EditDynBlock.zipEdit Dynamic Block14 Kb479
 

Add comment


Security code
Refresh

This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade