Code:
Option Strict Off
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.DrawingsModule NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim ufSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim curDwg As DrawingSheet = workPart.DrawingSheets().CurrentDrawingSheet
Dim theName As String = "REFERENZMASSE"
Dim objList As ArrayList = New ArrayList
Dim aTag As Tag = Tag.Null
Dim bTag As Tag = Tag.Null
ufSession.Obj.CycleByName(theName, aTag)
If aTag = Tag.Null Then
Dim modes As ImportPartModes
Dim group As NXOpen.Tag
modes.group_mode = 1
Dim file_name As String = "O:\SiemensNX\BCTSI\custom\siemens\nx100\rahmen\Referenzmasse.prt"
Dim dest_csys() As Double = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}
Dim scale As Double = 1.0
Dim dwgWidth As Double = curDwg.Length
Dim dest_point() As Double = {0, 0, 0}
dest_point = {dwgWidth+20, 0, 0}
ufSession.Part.Import(file_name, modes, dest_csys, dest_point, scale, group)
Else
Do
ufSession.Obj.CycleByName(theName, bTag)
objList.Add(NXObjectManager.Get(bTag))
Loop Until bTag = Tag.Null
Dim theObjects() = objList.ToArray(GetType(NXObject))
Dim theMarkId As Session.UndoMarkId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete Objects Named" + theName)
theSession.UpdateManager.AddToDeleteList(theObjects)
theSession.UpdateManager.DoUpdate(theMarkId)
End If
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module