How to Find all the entities in a layer.

The VBA forum deals with IntelliCAD 2000 VBA (Visual Basic for Applications) issues.

Moderator: CMS Inc

Post Reply
wonton
Newbie
Posts: 4
Joined: Wed Jul 07, 2010 9:22 am

How to Find all the entities in a layer.

Post by wonton » Wed Jul 21, 2010 10:39 am

Hi

I want to delete all layers starting with a certain name, which I can do as long as the layer is empty.

My question is - How do you find all the entities in a layer, so I can then delete them and so therefore delete the layer?

Thanks in advance
Phil
JCAMPOS

Post by JCAMPOS » Thu Jul 22, 2010 2:55 am

Hi wonton,

You can use a selection set with filter by Layer. Here is an example on how to delete all the entities drawn on "MyLayer":

Code: Select all

Public Sub DeleteAllEntitiesInMyLayer()

    'Initializes a new SelectionSet:
    Dim sset As IntelliCAD.SelectionSet
    
    'Defines the filter for the SelectionSet:
    Dim filterTypes(0) As Integer
    Dim filterData(0) As Variant
    filterTypes(0) = 8: filterData(0) = "MyLayer"
        
    'Creates the selection using the SelectionSet:
    Set sset = IntelliCAD.ActiveDocument.SelectionSets.Add("MyLayerSSet")
    Call sset.Select(IntelliCAD.SelectionSetType.vicSelectionSetAll, , , filterTypes, filterData)
        
    Dim i As Integer
    Dim ent As IntelliCAD.entity
        
    For i = 1 To sset.Count
        
        'Gets the entity:
        Set ent = sset.Item(i)
                
        'Deletes the entity:
        ent.Delete
                
    Next i
        
End Sub
Regards,
JCAMPOS
wonton
Newbie
Posts: 4
Joined: Wed Jul 07, 2010 9:22 am

Post by wonton » Thu Jul 22, 2010 4:34 am

Thanks again
Post Reply