You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
7.2 KiB
192 lines
7.2 KiB
' NX 1953
|
|
' Journal created by naikss on Fri Mar 18 13:37:38 2022 India Standard Time
|
|
'
|
|
Imports System
|
|
Imports NXOpen
|
|
Imports NXOpenUI
|
|
Imports NXOpen.UF
|
|
Imports NXOpen.Utilities
|
|
Imports System.Threading
|
|
Imports System.Threading.Tasks
|
|
Imports NXOpen.Assemblies
|
|
|
|
Module NXJournal
|
|
Public ufs As UFSession = UFSession.GetUFSession
|
|
Public thesession As Session = Session.GetSession
|
|
Public lw As ListingWindow = theSession.ListingWindow
|
|
Sub Main(ByVal args() As String)
|
|
Try
|
|
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, "Start")
|
|
|
|
'################## COMPONENT BUILDER
|
|
|
|
Dim addComponentBuilder1 As NXOpen.Assemblies.AddComponentBuilder = Nothing
|
|
addComponentBuilder1 = workPart.AssemblyManager.CreateAddComponentBuilder()
|
|
|
|
|
|
'################## COMPONENT POSITIONER
|
|
|
|
Dim componentPositioner1 As NXOpen.Positioning.ComponentPositioner = Nothing
|
|
componentPositioner1 = workPart.ComponentAssembly.Positioner
|
|
componentPositioner1.ClearNetwork()
|
|
Dim arrangement1 As NXOpen.Assemblies.Arrangement = CType(workPart.ComponentAssembly.Arrangements.FindObject("Arrangement 1"), NXOpen.Assemblies.Arrangement)
|
|
componentPositioner1.PrimaryArrangement = arrangement1
|
|
componentPositioner1.BeginAssemblyConstraints()
|
|
|
|
Dim allowInterpartPositioning1 As Boolean = Nothing
|
|
allowInterpartPositioning1 = theSession.Preferences.Assemblies.InterpartPositioning
|
|
|
|
'Dim nullNXOpen_Unit As NXOpen.Unit = Nothing
|
|
|
|
|
|
'################## UNIT DEFINATION
|
|
|
|
Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)
|
|
Dim unit2 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("Degrees"), NXOpen.Unit)
|
|
|
|
|
|
|
|
'################## COMPONENT NETWOK
|
|
|
|
Dim network1 As NXOpen.Positioning.Network = Nothing
|
|
network1 = componentPositioner1.EstablishNetwork()
|
|
Dim componentNetwork1 As NXOpen.Positioning.ComponentNetwork = CType(network1, NXOpen.Positioning.ComponentNetwork)
|
|
componentNetwork1.MoveObjectsState = True
|
|
Dim nullNXOpen_Assemblies_Component As NXOpen.Assemblies.Component = Nothing
|
|
componentNetwork1.DisplayComponent = nullNXOpen_Assemblies_Component
|
|
theSession.SetUndoMarkName(markId1, "Add Component Dialog")
|
|
componentNetwork1.MoveObjectsState = True
|
|
|
|
|
|
|
|
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
|
|
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Assembly Constraints Update")
|
|
|
|
Dim nullNXOpen_Assemblies_ProductInterface_InterfaceObject As NXOpen.Assemblies.ProductInterface.InterfaceObject = Nothing
|
|
|
|
|
|
|
|
'#####################################################################################################################################################
|
|
|
|
theSession.PdmSession.SetNativeMode(True, False)
|
|
|
|
Dim basePart1 As NXOpen.BasePart = Nothing
|
|
Dim partLoadStatus1 As NXOpen.PartLoadStatus = Nothing
|
|
|
|
|
|
|
|
basePart1 = theSession.Parts.OpenBase("D:\tool1.prt", partLoadStatus1)
|
|
|
|
partLoadStatus1.Dispose()
|
|
theSession.PdmSession.SetNativeMode(False, False)
|
|
|
|
|
|
addComponentBuilder1.ReferenceSet = "Use Model"
|
|
|
|
addComponentBuilder1.Layer = -1
|
|
|
|
Dim partstouse1(0) As NXOpen.BasePart
|
|
Dim part1 As NXOpen.Part = CType(basePart1, NXOpen.Part)
|
|
|
|
partstouse1(0) = part1
|
|
addComponentBuilder1.SetPartsToAdd(partstouse1)
|
|
|
|
'#####################################################################################################################################################
|
|
|
|
|
|
|
|
Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
|
|
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")
|
|
|
|
|
|
|
|
|
|
theSession.SetUndoMarkName(markId3, "Point")
|
|
|
|
|
|
|
|
|
|
workPart.MeasureManager.SetPartTransientModification()
|
|
|
|
workPart.MeasureManager.ClearPartTransientModification()
|
|
|
|
theSession.DeleteUndoMark(markId3, Nothing)
|
|
|
|
'#####################################################################################################################################################
|
|
|
|
Dim point6 As NXOpen.Point3d = New NXOpen.Point3d(153.0, 238.0, 385.0)
|
|
|
|
'#####################################################################################################################################################
|
|
|
|
Dim orientation1 As NXOpen.Matrix3x3 = Nothing
|
|
orientation1.Xx = 1.0
|
|
orientation1.Xy = 0.0
|
|
orientation1.Xz = 0.0
|
|
orientation1.Yx = 0.0
|
|
orientation1.Yy = 1.0
|
|
orientation1.Yz = 0.0
|
|
orientation1.Zx = 0.0
|
|
orientation1.Zy = 0.0
|
|
orientation1.Zz = 1.0
|
|
addComponentBuilder1.SetInitialLocationAndOrientation(point6, orientation1)
|
|
|
|
|
|
'#####################################################################################################################################################
|
|
|
|
|
|
componentNetwork1.Solve()
|
|
|
|
componentPositioner1.ClearNetwork()
|
|
|
|
Dim nErrs1 As Integer = Nothing
|
|
nErrs1 = theSession.UpdateManager.AddToDeleteList(componentNetwork1)
|
|
|
|
Dim nErrs2 As Integer = Nothing
|
|
nErrs2 = theSession.UpdateManager.DoUpdate(markId2)
|
|
|
|
componentPositioner1.EndAssemblyConstraints()
|
|
|
|
Dim logicalobjects1() As NXOpen.PDM.LogicalObject
|
|
addComponentBuilder1.GetLogicalObjectsHavingUnassignedRequiredAttributes(logicalobjects1)
|
|
|
|
addComponentBuilder1.ComponentName = "TOOL1"
|
|
|
|
Dim nXObject1 As NXOpen.NXObject = Nothing
|
|
nXObject1 = addComponentBuilder1.Commit()
|
|
|
|
Dim errorList1 As NXOpen.ErrorList = Nothing
|
|
errorList1 = addComponentBuilder1.GetOperationFailures()
|
|
|
|
errorList1.Dispose()
|
|
|
|
|
|
theSession.SetUndoMarkName(markId1, "Add Component")
|
|
|
|
addComponentBuilder1.Destroy()
|
|
|
|
|
|
|
|
Dim nullNXOpen_Assemblies_Arrangement As NXOpen.Assemblies.Arrangement = Nothing
|
|
|
|
componentPositioner1.PrimaryArrangement = nullNXOpen_Assemblies_Arrangement
|
|
|
|
theSession.DeleteUndoMark(markId2, Nothing)
|
|
|
|
theSession.CleanUpFacetedFacesAndEdges()
|
|
|
|
|
|
Catch ex As Exception
|
|
lw.WriteLine("error" & ex.ToString)
|
|
End Try
|
|
End Sub
|
|
Public Function GetUnloadOption(ByVal dummy As String) As Integer
|
|
Return CType(NXOpen.Session.LibraryUnloadOption.Immediately, Integer)
|
|
End Function
|
|
End Module
|