i try to run the code from GTAC, but gives me error message
i try to run the code from GTAC, but gives me error message
(OP)
i am studying the code from GTAC.
the code is to update all parts and all drawing. but when i run, it gives error:
Nxopen.Nxexception. part or occurence is not a descendant of the root part
at NXopen.parCollection.Setwork(Basepart.part)
what does this error mean?
what i did is create 4 models, save them ,and then open up each of them and finally run the code to see what happen,
but now it's error..
the code is to update all parts and all drawing. but when i run, it gives error:
Nxopen.Nxexception. part or occurence is not a descendant of the root part
at NXopen.parCollection.Setwork(Basepart.part)
what does this error mean?
what i did is create 4 models, save them ,and then open up each of them and finally run the code to see what happen,
but now it's error..
CODE --> vb
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.Drawings
Module update_all_parts_then_update_all_drawings
Dim s As Session = Session.GetSession()
Dim ufSess As UFSession = UFSession.GetUFSession()
Sub Main()
ufSess.Modl.SetUpdateFailOption(UFModl.UpdateOption.UpdateAcceptAll)
Dim o_wp As Part = s.Parts.Work()
Dim layout1 As Layout = CType(o_wp.Layouts.FindObject("L1"), Layout)
'layout1.Open()
For Each prt As Part In s.Parts
this line gives trouble.
s.Parts.SetWork(prt)
ufSess.Modl.UpdateAllFeatures()
Next
s.Parts.SetWork(o_wp)
Dim mark1 As Session.UndoMarkId
mark1 = s.SetUndoMark(Session.MarkVisibility.Invisible, "")
s.UpdateManager.DoInterpartUpdate(mark1)
For Each dwg As DrawingSheet In o_wp.DrawingSheets
' Sometimes updating a specific view will cause a previously updated
' view to become out-of-date again, so this is While not If
While dwg.IsOutOfDate
For Each dv As DraftingView In dwg.GetDraftingViews()
If dv.IsOutOfDate Then
dv.Update()
End If
Next
End While
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module 




RE: i try to run the code from GTAC, but gives me error message
It seems this code was meant to operate only on an assembly and its components. Create a test assembly, make it the display part (close any parts that do not belong to the assembly as components) and try running the code. It should make each of the components the work part in turn and perform an update on each.
www.nxjournaling.com
RE: i try to run the code from GTAC, but gives me error message
one more questions,
if i want to update severl models, no assemlby file involved, do i only have to revise the code to :
For Each prt As Part In s.Parts
ChangeDisplayPart(prt) <---------- does this do the trick?
ufSess.Modl.UpdateAllFeatures()
Next
RE: i try to run the code from GTAC, but gives me error message
www.nxjournaling.com