Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro to change all the Leader Symbol shapes to Filled Circle

Status
Not open for further replies.

GopinadhGvs

Mechanical
Mar 30, 2015
4
macro to change all the Leader Symbol shapes to Filled Circle

Here is the macro i am trying, to change the leader symbol shape for all texts having leaders.

'Option Explicit
Sub CATMain()
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection1 As Object
Set selection1 = drawingDocument1.Selection
selection1.Search "(CATTPSSearch.CATTPSText + CATDrwSearch.DrwText), all"

Dim oText As DrawingText
Dim oLeader As DrawingLeader
For i = 1 To selection1.Count2
    Set oText = selection1.Item2(i).Value  
    If oText.Leaders.Count > 0 Then             -> Error is here
        For Each oLeader In oText.Leaders
            oLeader.HeadSymbol = catFilledCircle
        Next
    End If
Next
End Sub

Please help me to solve this issue..
 
Replies continue below

Recommended for you

My guess is you cannot count the number of leaders because there is no Count method. Try removing the If and end if.

DrawingLeaders (Collection)
IUnknown
|
+---IDispatch
|
+---CATBaseUnknown
|
+---CATBaseDispatch
|
+---Collection
|
+---DrawingLeaders


--------------------------------------------------------------------------------

A collection of all the drawing leaders currently managed by a drawing view of drawing sheet in a drawing document.

--------------------------------------------------------------------------------

Method Index
Add
Creates a drawing leader and adds it to the DrawingLeaders collection.
Item
Returns a drawing leader using its index from the DrawingLeaders collection.
Remove
Removes a drawing leader from the DrawingLeaders collection.
 
your code works well, no error for me when the view does have few texts to which I did add a multi leader and some text with leader and some other stuff like datum target, balloon and welding symbol.

the view still have its name and this text is picked by the search, but this did not crash the script as leaders.count come back with value 0.

Try to identify which text your script fails on and work on it, maybe a text is corrupted? did you clean the drawing?

Can you post the drawing with the failing text?

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor