Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Isolate External References Macro

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
236
Is there a macro that will search an assembly and select all external references and Isolate them?
I would like to isolate every reference except those pointing to Published elements.
 
Replies continue below

Recommended for you

I tried for quite a while in VBA to find:
[ul]
[li]If an external reference is bad/not connected[/li]
[li]The parent of an external reference[/li]
[/ul]

From my experience:
[ul]
[li]Differentiating between a good and bad external reference is not an exposed API...You would likely need CAA to do this[/li]
[li]Getting the parent of the external reference was also not exposed, nor was the path of the external reference. All you could really do was collect all publications from all the parts in the loaded product and check to see if the name of the external reference matches the name of any of the publications. This is not a good way to do it because:[/li]
[li]You can rename external references or publications so the names don't match[/li]
[li]You can have several publications from different parts with the same name so you might get a false positive[/li]
[li]It takes a really long time to keep looping through all the publication names over and over and over, trying to find a match...users hated it[/li]​
[/ul]
 
Dim i As Integer, j As Integer
For i = 1 To myDocuments.Count
If InStr(1, myDocuments.Item(i).Name, ".CATPart") > 0 And InStr(1, myDocuments.Item(i).Name, ".CATProduct") <= 0 Then
myPart = myDocuments.Item(i).Part
Dim iBodyCnt As Integer
iBodyCnt = myPart.HybridBodies.Count
For j = 1 To iBodyCnt
If j >= iBodyCnt Then Exit For
If myPart.HybridBodies.Item(j).Name = "External References" Then
Dim myHBBody As HybridBody
myHBBody = myPart.HybridBodies.Item(j)
Dim k As Integer
For k = 1 To myHBBody.HybridShapes.Count
Debug.Print(myPart.Name & " - " & myHBBody.HybridShapes.Item(k).Name)
mySelection.Add(myHBBody.HybridShapes.Item(k))
iCnt = iCnt + 1
Next
If mySelection.Count2 > 0 Then
' Create Alias for Isolate
'CATIA.StartCommand("IsolateObject")
CATIA.StartCommand("Isolate")
mySelection.Clear()
End If
End If
Next
End If
Next
MsgBox("Isolating " & iCnt & " External Referances - Done", vbInformation, "Isolate External Referances")
 
I thought the goal was to only isolate features that weren't linked?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor