Tree Organize Assembly

Valued Contributor
Valued Contributor

 

Bom dia!

É possível criar um código que ordene a árvore de construção de um assembly?

Reposicionando conforme a necessidade?

Edson Jesus

Good morning!

You can create a code that orders the tree to build an assembly?

Repositioning as needed?

Edson Jesus

 

Posted by: Edson Silva de Jesus
Post date: 12/7/2009 10:53:49 PM

2 REPLIES

RE: Tree Organize Assembly

Valued Contributor
Valued Contributor

I think this is what you are after. This is in VB6 and sorts based on Filename:

 

Sub Main()

'

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

'

On Error GoTo 100

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

GoTo 150

100 MsgBox "There are not any 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

'

' Connect to active document

'

Set objDoc = objApp.ActiveDocument

'

' Prepare to begin sorting process

'

If objApp.ActiveDocument.Occurrences.Count = 0 Then

MsgBox "There is nothing to sort!", vbOKOnly, "Assembly has no components."

End

End If

' Determine and assign looping based on total child count

'

With objApp.ActiveDocument.Occurrences

For x = 1 To .Count - 1

objApp.StatusBar = "Sorting " & .Item(x + 1).Name & " -- (Item " & x & " of " & .Count & ")"

' If the next item is less than the current item

If UCase(.Item(x + 1).Name)

' It is, so check against all previous items to this point

y = 1

For z = 1 To .Count - 1

If UCase(.Item(x + 1).Name)

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

Exit For

End If

y = y + 1

Next

End If

Next

End With

objApp.StatusBar = ""

End Sub

 

Posted by: Bill Ledbetter
Post date: 12/9/2009 2:40:24 AM

RE: Tree Organize Assembly

Valued Contributor
Valued Contributor

Hello Bill, sorry for answering only now.

I would like to thank him for his help.

A big hug

Edson

 

Posted by: Edson Silva de Jesus
Post date: 5/3/2010 2:06:59 AM