niedzviedz
Mechanical
- Apr 1, 2012
- 307
Hello everyone,
I have created journal to export step203 from selected bodies, but I receive error:
The same journal, but used step214creator work perfect. What I'm doing wrong?
Below Is my code.
With best regards
Michael
I have created journal to export step203 from selected bodies, but I receive error:
*** ERROR ***
3600002 : Symbol not found in library
The same journal, but used step214creator work perfect. What I'm doing wrong?
Below Is my code.
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports Microsoft.VisualBasic
Module NXJournal
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim mySelectedObjects() As NXObject
Dim myResponse As Selection.Response
Dim tagList() As NXOpen.Tag
Dim exportFileName As String = Nothing
Dim exportFileName1 As String = Nothing
Dim nazwa as string
Dim path As String
Dim step203File As String
Dim STEP203UG_DIR As String = theSession.GetEnvironmentVariableValue("STEP203UG_DIR")
step203File = IO.Path.Combine(STEP203UG_DIR, "ugstep203.def")
lw.Open()
If Not IO.File.Exists(step203File) Then
MsgBox("The step203 settings file (ugstep203.def) was not found." & vbCrLf & _
"This journal will now exit.", vbOKOnly + vbCritical)
Exit Sub
Else
'lw.WriteLine("STEP203 definition file found at: " & step203File)
End If
Dim i As Integer = 0
myResponse = SelectObjects(mySelectedObjects)
If (myResponse = Selection.Response.Cancel) OrElse (myResponse = Selection.Response.Back) Then
'user canceled selection, exit journal
Exit Sub
End If
ReDim tagList(mySelectedObjects.GetUpperBound(0))
For i = 0 To mySelectedObjects.GetUpperBound(0)
tagList(i) = mySelectedObjects(i).Tag
Next
'return the full path of the work part
exportFileName = workPart.FullPath
nazwa = workPart.Leaf
path = IO.Path.Combine(IO.Path.GetDirectoryName(workPart.FullPath), "step")
If(Not System.IO.Directory.Exists(Path)) Then
System.IO.Directory.CreateDirectory(Path)
End If
exportFileName = IO.Path.Combine(path, nazwa & ".stp")
'if this file already exists, delete it
If My.Computer.FileSystem.FileExists(exportFileName) Then
My.Computer.FileSystem.DeleteFile(exportFileName)
End If
Dim numUnexported As Integer
Try
' ufs.Ps.ExportLinkedData(Taglist, Taglist.Length, exportFileName, PSversion, Nothing, numUnexported,
Nothing)
Dim step203Creator1 As Step203Creator
step203Creator1 = theSession.DexManager.CreateStep203Creator()
step203Creator1.SettingsFile = step203File
step203Creator1.ObjectTypes.Solids = True
step203Creator1.LayerMask = "1-256"
step203Creator1.InputFile = workPart.FullPath
step203Creator1.OutputFile = exportfilename
step203Creator1.FileSaveFlag = False
step203Creator1.BsplineTol = 0.0001
Step203Creator1.ColorAndLayers = 1
step203Creator1.ExportSelectionBlock.SelectionScope = ObjectSelector.Scope.SelectedObjects
Dim nXObject1 As NXObject
nXObject1 = step203Creator1.Commit()
step203Creator1.Destroy()
lw.Close()
Catch ex As NXException
lw.WriteLine("*** ERROR ***")
lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
End Try
lw.Close()
End Sub
Function SelectObjects(ByRef selobj() As NXObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim prompt as String = "Select Solid Bodies"
Dim title As String = "Selection"
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.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
End With
Dim resp As Selection.Response = _
theUI.SelectionManager.SelectObjects( _
prompt, title, scope, selAction, _
includeFeatures, keepHighlighted, _
selectionMask_array, selobj)
Return resp
End Function
End Module
With best regards
Michael