×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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..


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

Quote (.net API reference, SetWork Method remarks)

The work component will be set to one of the visible components that represent this part in the current visible assembly. See SetWorkComponent . If no visible component is available, then an exception is thrown.

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

(OP)
yes, it runs!!!!

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

I suggest you look up the PartCollection.SetDisplay() method in the documentation...

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources