Skip to main content
1-Visitor
November 10, 2011
Question

Delete unused pens (without locked and invisible selection )

  • November 10, 2011
  • 0 replies
  • 870 views

Hi everybody, is they have any way to incorporate someting in this macro to do not delete line who is lock or invisible???

Thank to all!!!

Macro Delete_Unused_Pens

Define p as Integer
Define i as Integer
Define CheckMe as String
Define E1 as Element

Zoom Page
Select None
Wait Timer 1

#Sets values of variables.
i = ActiveDoc.PenCount

p = 1

#Starts loop that goes through all existing pens.
While ((p <> i + 1) = True)

Select None

CheckMe = ActiveDoc.Pens[p].Name

Select if Pen is equal to CheckMe

If (Exists (ActiveDoc.FirstSelectedElement) = False) Then
Set Active Pen CheckMe
Create Line 0 0 1 1
E1 = ActiveDoc.FirstSelectedElement
Create object_info E1
E1.Info.Name = "Delete_Me"

On Error Goto WhoCares
Delete Pen CheckMe "$ISO_NOPEN"

Else
p = p + 1
End If

#Reduce number of overall pens because of pen deletion.
i = ActiveDoc.PenCount

End While

Select None
Select if Object_Name is Equal to 'Delete_Me'
Delete Selection
Select None
Zoom Page

End Macro


SubMacro WhoCares
End Submacro