-
2
- #1
cowski
Mechanical
- Apr 23, 2000
- 8,184
While searching for journals to export parasolid files, I ran across an old thread:
thread561-277942
Here is a fixed version of that journal:
Hopefully it will help someone.
thread561-277942
Here is a fixed version of that journal:
Code:
'eng-tips.com thread561-277942
'journal to export all solids on work layer to parasolid file
Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module NXJournal
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
Sub Main
dim wlayer as integer = workPart.layers.worklayer
dim objs as NXObject()=workpart.layers.getallobjectsonlayer(wlayer)
dim obj as NXObject
dim taglst() as Tag
dim t as tag
dim x as integer=0
dim b as body
Dim strParasolid as string
for each obj in objs
if obj.gettype.tostring="NXOpen.Body" then
b=CTYPE(obj,Body)
redim preserve taglst(x)
taglst(x)=b.tag
x=x+1
end if
next
strParasolid = GetFilePath() & GetFileName() & ".x_t"
ufs.Ps.exportdata(taglst, strParasolid)
End Sub 'end of Sub Main
'***********************************************************************
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
'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)
GetFilePath = strPath
End Function
End Module
Hopefully it will help someone.