Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make workpart through journal

Status
Not open for further replies.

spadazenon

Mechanical
Mar 28, 2010
49
Dear all,

When I try to run this journal, it should make the subassembly as the workpart, before the message in the msgbox displays. I cannot make it work. The message displays before the subassembly becomes the workpart. Can anyone help me out here?

---------------------------------
' NX 11.0.0.33
' Journal created by spada on Mon Jan 23 20:52:55 2017 GTB Standard Time
'
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Make Work Part")

Dim component1 As NXOpen.Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT SUBASM-A 1"), NXOpen.Assemblies.Component)

Dim partLoadStatus1 As NXOpen.PartLoadStatus = Nothing
theSession.Parts.SetWorkComponent(component1, NXOpen.PartCollection.RefsetOption.Entire, NXOpen.PartCollection.WorkComponentOption.Visible, partLoadStatus1)

workPart = theSession.Parts.Work ' SUBASM-A
partLoadStatus1.Dispose()
theSession.SetUndoMarkName(markId1, "Make Work Part")

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
msgbox("This should display after the subassembly becomes workpart")
End Sub

End Module
 
Replies continue below

Recommended for you

I would try calling the .DoUpdate and/or the .UpdateDisplay methods after changing the work part and before displaying the message box.

www.nxjournaling.com
 
Thank you cowski,

I managed to use DisplayPart.ModelingViews.WorkView.UpdateDisplay() but sometimes it seems to update the display to the first feature. I couldn't use the .DoUpdate method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor