Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX1969 - Import Team Center File Journal

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
0
0
US
I have figured out how to import a team center file into another team center file. Here is where I really suck in VB code. User selection. lol

Would this be terribly difficult to set up two different ways?
1) To allow user to select an existing point where to place it.
2) To allow user to select an End Point where to place it.

In both cases, I would like to add a loop so it allows the user to keep placing new ones to new locations until they click OK or Cancel.


Code:
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")

        workPart.Layers.WorkLayer = 253

        Dim partImporter1 As PartImporter
partImporter1 = workPart.ImportManager.CreatePartImporter()

partImporter1.FileName = "R:\hms_tools\NX1872\Tooling\part\Notes\View_Z.prt"

partImporter1.Scale = 1.0

partImporter1.CreateNamedGroup = False

partImporter1.ImportViews = False

partImporter1.ImportCamObjects = False

partImporter1.LayerOption = PartImporter.LayerOptionType.Work

partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work

Dim element1 As Matrix3x3
element1.Xx = 1.0
element1.Xy = 0.0
element1.Xz = 0.0
element1.Yx = 0.0
element1.Yy = 1.0
element1.Yz = 0.0
element1.Zx = 0.0
element1.Zy = 0.0
element1.Zz = 1.0
Dim nXMatrix1 As NXMatrix
nXMatrix1 = workPart.NXMatrices.Create(element1)

partImporter1.DestinationCoordinateSystem = nXMatrix1

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


Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Status
Not open for further replies.
Back
Top