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 Count the Number of Leaders Associated with a 2D Component

Status
Not open for further replies.

Med Che

New member
Oct 21, 2023
7
TN
Hi,

I am working on a macro that calculates the number of leaders associated with a 2D component in a CATIA drawing. I have created the macro, but I can't count the number of leaders for the 2D component (the component I want to count the leaders for is a Bonding symbol). Here is my macro:
***********************
Sub Bonding_Count()
Dim doc1 As Object
Set doc1 = CATIA.ActiveDocument
Dim mycomponent As Object
Dim mysel As Object
Set mysel = doc1.Selection
Dim mySheet As Object
Set mySheet = doc1.sheets
'MsgBox mySheet.Item(1).Name
Dim myview As Object
Set myview = mySheet.Item(1).views
mysel.Clear

mysel.Add myview.Item("VIEW AP")
mysel.Clear
mysel.Search "CATDrwSearch.DrwDitto,all"
MsgBox TypeName(mysel.Item(1).Value)
MsgBox mysel.Item(1).Value.leaderCount
End Sub
**************************************
And here is a part of the view where there is a Bonding linked by two leaders.
Bonding_Leaders_klath7.jpg


Thank you for helping me achieve my goal.
 
Not possible with a macro.
 
Thank you for everything, and thank you for the solutions you proposed, but I can't find a solution to my problem
I write this :
Dim myleader1 as object
Set myleader1 = myview.item(1).leaders.count
I made a mistake on that line and i think the methode leaders not support with variable drawingview
 
Hello , Can I manipulate the leader linked to a Ditto on a drawing using VBA?
 
No, you can't. It is only possible to manipulate text or table leaders.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor