[s][/s]Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Module NXJournal
Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim currentPath as string
Dim currentFile as string
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Sub Main()
currentPath = GetFilePath()
currentFile = GetFileName()
Dim abody() As TaggedObject
If SelectBodies("select bodies", abody) = Selection.Response.Cancel Then
Return
End If
Dim bodyTags As New List(Of Tag)
For Each temp As TaggedObject In abody
bodyTags.Add(temp.Tag)
Next
Dim options As UFPart.ExportOptions
With options
.expression_mode = UFPart.ExportExpMode.CopyExpShallowly
.new_part = True
.params_mode = UFPart.ExportParamsMode.RemoveParams
End With
theUFSession.Part.ExportWithOptions(currentPath & "\" & currentFile & " crowns-overlay", bodyTags.Count, bodyTags.ToArray, options)
End Sub
Function SelectBodies(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select one or more bodies"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Function GetFileName()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Left(strPath, pos)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
GetFileName = strPart
End Function
'***********************************************************************
Function GetFilePath()
Dim strPath as String
Dim strPart as String
Dim pos as Integer
Dim pos2 as Integer
'get the full file path
strPath = displayPart.fullpath
'get the part file name
pos = InStrRev(strPath, "\")
strPart = Mid(strPath, pos + 1)
strPath = Left(strPath, pos - 1)
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
'pos2 = InStrRev(strPath, "\")
'strPath = Left(strPath, pos2)
GetFilePath = strPath
End Function
End Module