| Change Object in Block |
|
|
|
| Tutorials | |||
|
This routines enters a block by name, searches for a specific object in a specific layer and changes the color of that object. Sample block used for this routine has the blockname BlkSample and controls LINE objects in the layer LAYER10 Code: Function ChangeObjectinBlock()
'***************************************************
'******* Code from VisibleVisual.com ***************
'******* Change the color of a Layer in a block ****
'***************************************************
Dim BlkObject As AcadBlock
Dim Ent As AcadEntity
Set BlkObject = ThisDrawing.Blocks.Item("BlkSample") 'Set block
For z = 0 To BlkObject.Count - 1 'Cycle through the entities in the block
Set Ent = BlkObject.Item(z)
If Ent.ObjectName = "AcDbLine" Then 'Check if the entity is a Line Object
If Ent.Layer = "Layer10" Then 'Check if the line is in Layer10
Ent.Color = acRed 'Change the color of the Line to Red
End If
End If
Next z
'Regen the viewport to make the changes visible
ThisDrawing.Regen acAllViewports
End Function
|


