Kenja824
Automotive
- Nov 5, 2014
- 949
In the following code, the part file that is imported is always automatically placed. Would it be a difficult change to allow the user to select a center-point of a circle, or even a cursor location, to place where the 0,0,0 of the imported file will land?
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: File->Import->Part...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Import Part")
Dim partImporter1 As PartImporter
partImporter1 = workPart.ImportManager.CreatePartImporter()
partImporter1.FileName = "R:\hms_tools\NX9\Tooling\part\Notes\black_oxide.prt"
partImporter1.Scale = 1.0
partImporter1.CreateNamedGroup = False
partImporter1.ImportViews = False
partImporter1.ImportCamObjects = False
partImporter1.LayerOption = PartImporter.LayerOptionType.Work
partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work
partImporter1.DestinationCoordinateSystem = workPart.WCS.CoordinateSystem.Orientation
Dim destinationPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
partImporter1.DestinationPoint = destinationPoint1
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part Commit")
Dim nXObject1 As NXObject
nXObject1 = partImporter1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
partImporter1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: File->Import->Part...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Import Part")
Dim partImporter1 As PartImporter
partImporter1 = workPart.ImportManager.CreatePartImporter()
partImporter1.FileName = "R:\hms_tools\NX9\Tooling\part\Notes\black_oxide.prt"
partImporter1.Scale = 1.0
partImporter1.CreateNamedGroup = False
partImporter1.ImportViews = False
partImporter1.ImportCamObjects = False
partImporter1.LayerOption = PartImporter.LayerOptionType.Work
partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work
partImporter1.DestinationCoordinateSystem = workPart.WCS.CoordinateSystem.Orientation
Dim destinationPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
partImporter1.DestinationPoint = destinationPoint1
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part Commit")
Dim nXObject1 As NXObject
nXObject1 = partImporter1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
partImporter1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module