DesEngineer4
Mechanical
- Feb 19, 2013
- 181
Hi all,
Now I will try to explain you better about my reference set requirements (Please see the attachments)
I have attached one model images for example:
A model contains 5 sub level assemblies and each sub assembly contain there individual reference sets say model ( Please See image 1). Now I will create a new reference set say T/L (Top Level) and i will move all sub assembly components to that "T/L" reference set. (Please See Image 2 & 3)
Now my requirement is Can we do the above procedure automatically. That i am using below journal which was recorded through NX, This journal is working for current model only. But, I need this journal to use for any model or any assembly part. (which creates new reference set and should move all components to that reference set). Please guide me. I hope so, you understood my requirement. Thanks for your patience.
Thanks & Regards,
Sam
Now I will try to explain you better about my reference set requirements (Please see the attachments)
I have attached one model images for example:
A model contains 5 sub level assemblies and each sub assembly contain there individual reference sets say model ( Please See image 1). Now I will create a new reference set say T/L (Top Level) and i will move all sub assembly components to that "T/L" reference set. (Please See Image 2 & 3)
Now my requirement is Can we do the above procedure automatically. That i am using below journal which was recorded through NX, This journal is working for current model only. But, I need this journal to use for any model or any assembly part. (which creates new reference set and should move all components to that reference set). Please guide me. I hope so, you understood my requirement. Thanks for your patience.
Code:
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Format->Reference Sets...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
theSession.SetUndoMarkName(markId1, "Reference Sets Dialog")
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create New Reference Set")
Dim referenceSet1 As ReferenceSet
referenceSet1 = workPart.CreateReferenceSet()
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Add Components to Reference Set")
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId2)
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Name of Reference Set")
referenceSet1.SetName("T/L")
Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId4)
Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Objects of Reference Set")
Dim components1(0) As NXObject
Dim component1 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT sub level 1 1"), Assemblies.Component)
components1(0) = component1
referenceSet1.AddObjectsToReferenceSet(components1)
Dim nErrs3 As Integer
nErrs3 = theSession.UpdateManager.DoUpdate(markId5)
Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Objects of Reference Set")
Dim components2(0) As NXObject
Dim component2 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT sub level 2 1"), Assemblies.Component)
components2(0) = component2
referenceSet1.AddObjectsToReferenceSet(components2)
Dim nErrs4 As Integer
nErrs4 = theSession.UpdateManager.DoUpdate(markId6)
Dim markId7 As Session.UndoMarkId
markId7 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Objects of Reference Set")
Dim components3(0) As NXObject
Dim component3 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT sub level 3 1"), Assemblies.Component)
components3(0) = component3
referenceSet1.AddObjectsToReferenceSet(components3)
Dim nErrs5 As Integer
nErrs5 = theSession.UpdateManager.DoUpdate(markId7)
Dim markId8 As Session.UndoMarkId
markId8 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Objects of Reference Set")
Dim components4(0) As NXObject
Dim component4 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT sub level 4 1"), Assemblies.Component)
components4(0) = component4
referenceSet1.AddObjectsToReferenceSet(components4)
Dim nErrs6 As Integer
nErrs6 = theSession.UpdateManager.DoUpdate(markId8)
Dim markId9 As Session.UndoMarkId
markId9 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Objects of Reference Set")
Dim components5(0) As NXObject
Dim component5 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT sub level 5 1"), Assemblies.Component)
components5(0) = component5
referenceSet1.AddObjectsToReferenceSet(components5)
Dim nErrs7 As Integer
nErrs7 = theSession.UpdateManager.DoUpdate(markId9)
theSession.DeleteUndoMarksUpToMark(markId3, Nothing, False)
theSession.SetUndoMarkName(markId1, "Reference Sets")
theSession.DeleteUndoMark(markId1, Nothing)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Thanks & Regards,
Sam