Hallo Zusammen,
habe hier ein kleines programm welches durch die ganze BG laufen soll und die Teile vom Reference Set auf ganzes Teil stellen soll.
Hier mein Programm:
Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Module NXJournal
Sub Main
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim parents As Tag()
If s.Parts.Work Is Nothing Then
Windows.Forms.MessageBox.Show("Kein Teil geladen! - No Part Loaded!")
Exit Sub
End If
'modulabfrage
Dim module_id As Integer = 0
ufs.UF.AskApplicationModule(module_id)
If module_id = UFConstants.UF_APP_DRAFTING Then
Windows.Forms.MessageBox.Show("Bitte ins Modeling wechseln / Please change to modeling")
Exit Sub
End If
For Each a_part As Part In s.Parts
Dim root As Component = a_part.ComponentAssembly.RootComponent
If Not root Is Nothing Then
ufs.Assem.WhereIsPartUsed(a_part.Tag, parents)
If parents.Length = 0 Then
Dim children As ArrayList = New ArrayList
getAllChildren(root, children)
Dim kids(children.Count - 1) As Component
Dim inx As Integer = 0
For Each obj As Object In children
kids(inx) = obj
inx = inx + 1
Next
a_part.ComponentAssembly.ReplaceReferenceSetInOwners( _
"Entire Part", kids)
End If
End If
Next
End Sub
Sub getAllChildren(ByVal comp As Component, ByRef children As ArrayList)
For Each child As Component In comp.GetChildren()
children.Add(child)
getAllChildren(child, children)
Next
End Sub
End Module
Jetzt bekomme ich hier ein problem (Zeile29) ComponentAssembly.RootComponent....
Ich glaube er findet den RootComponent nicht.
Hat jemand eine Idee?
Danke
------------------
Gruß
Michael
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP