' NX 7.5.4.4
' Journal created by xxxxxxxxxx on Wed May 09 14:03:06 2012 Central Daylight Time
' journal Copied from above on 03-15-13 xxxxxxxx to insert a standard note block.
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: File->Import->Part...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId1, "Import Part Dialog")
' ----------------------------------------------
' Dialog Begin Import Part
' ----------------------------------------------
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part")
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Import Part")
theSession.DeleteUndoMark(markId1, Nothing)
theSession.Parts.SetNonmasterSeedPartData("@DB/ST-Note-Block_english/P")
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Import Part")
Dim importer1 As Importer
importer1 = workPart.ImportManager.CreatePartImporter()
Dim partImporter1 As PartImporter = CType(importer1, PartImporter)
partImporter1.FileName = "@DB/ST-Note-Block_english/P"
partImporter1.Scale = 1.0
partImporter1.CreateNamedGroup = True
partImporter1.ImportViews = False
partImporter1.ImportCamObjects = False
partImporter1.LayerOption = PartImporter.LayerOptionType.original
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 x As Double = 0
Dim y As Double = 0
Dim shtName As String = workPart.DrawingSheets().CurrentDrawingSheet.Name()
Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject(shtName), Drawings.DrawingSheet)
'Sheet A
If DrawingSheet1.height = 8.5 Then
msgbox("Sheet size too small for ST Gear Note Block." & vbcrlf & "Use B or larger", vbokonly, "ST Gear Note Block")
Exit Sub
End If
'Sheet B
If DrawingSheet1.height = 11 Then
x = 6.5
y = 9.75
End If
'Sheet C
If DrawingSheet1.height = 17 Then
x = 11.5
y = 16.5
End If
'Sheet D
If DrawingSheet1.height = 22 Then
x = 23.5
y = 21.5
End If
'Sheet E
If DrawingSheet1.height = 34 Then
x = 33.1
y = 33.5
End If
'Sheet F
If DrawingSheet1.height = 28 Then
x = 29.5
y = 27.5
End If
Dim destinationPoint1 As Point3d = New Point3d(x, y, 0.0)
partImporter1.DestinationPoint = destinationPoint1
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part Commit")
Dim nXObject1 As NXObject
nXObject1 = partImporter1.Commit()
theSession.DeleteUndoMark(markId4, Nothing)
partImporter1.Destroy()
End Sub
End Module