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:
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
[indent][/indent][COLOR=#CC0000]this line gives trouble.[/color]
[COLOR=#CC0000]s.Parts.SetWork(prt)[/color]
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