Assembly Tree sorting

 

I am a former user of UniGraphics. One feature that was in UG was the ability to sort the Assembly Pathfinder on almost any property. Thus, finding parts was much easier. Has anyone written a macro, or is it even possible to access the Assembly Pathfinder to sort it programmatically?

Thanks,

 

Posted by: Bill Ledbetter
Post date: 9/27/2007 3:05:46 AM

4 REPLIES

RE: Assembly Tree sorting

 

Bill,

To my knowledge, it's not possible via the API.  They simply do not expose that level of control.  It might be possible through some serious Window hacking but I don't know what it would do to Edge.  Sounds like an ER to me.

 

Posted by: Jason Newell
Post date: 9/27/2007 8:53:22 AM

RE: Assembly Tree sorting

Actually Jason, I found a way. Even though your Spy (which is great, don't get me wrong) shows Assembly Occurrences alpha-numerically, SE doesn't appear to store them that way. Thus, the code below works (at leasst for me it does).

 

Public i As Integer

Public objApp As SolidEdgeFramework.Application

Public objDoc As SolidEdgeDocument

Public x

Public y

Public z

Sub main()

'

' Connect to Solid Edge. Ensure it is an Assembly file that is open.

'

Set objApp = GetObject(, "SolidEdge.Application")

GoTo 150

100 MsgBox "There is not and instances of Solid Edge running!", vbExclamation, "How did you even get to this point?"

150 Err.Clear

If objApp.ActiveDocumentType igAssemblyDocument Then

MsgBox "This program is only for Assemblies!", vbOKOnly, "Wrong document type ..."

End

End If

Set objDoc = objApp.ActiveDocument

With objApp.ActiveDocument.Occurrences

For x = 1 To .Count - 1

If .Item(x + 1).Name

y = 1

For z = 1 To .Count - 1

If .Item(x + 1).Name

.ReorderOccurrence .Item(x + 1), .Item(y), 1

End If

y = y + 1

Next

End If

Next

End With

End Sub

 

 

Thanks for the reply. If you have time, can you try it and see if it works for you too?

 

- Bill

 

Posted by: Bill Ledbetter
Post date: 9/27/2007 9:51:11 AM

RE: Assembly Tree sorting

 

Nice find Bill! There I go again not thinking "outside of the box". That's why I prefaced my answer "To my knowledge". I'll try to get to it next week sometime because right now I'm getting ready for a 1 1/2 week roadtrip.

 

Posted by: Jason Newell
Post date: 9/27/2007 4:43:50 PM

RE: Assembly Tree sorting

Thanks. Don't worry about testing it, unless your group would find it useful. I'm only mimicing functionality inherent in NX. I need to add some code to have options of what parameter or custom properties to sort by, but other than that it works just dandy.

- Bill

 

Posted by: Bill Ledbetter
Post date: 9/28/2007 1:45:17 AM