Home AutoCad VB Change Object in Block
23 | 02 | 2012
Main Menu
Search
Paypal Donation
So we can continue and expand this site
Content View Hits : 469528
Change Object in Block PDF Print E-mail
User Rating: / 2
PoorBest 
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
 

Attachments:
FileDescriptionFile sizeDownloads
Download this file (ChangeLayerInBlock.dvb)ChangeLayerInBlock.dvb 32 Kb193
 

Add comment


Security code
Refresh

Advertising

LOGON
Sponsored Links