elvin00
Industrial
- Oct 27, 2018
- 3
Hi,
I usually work with this journal to export from NX to parasolid (all the ensemble with all the parts,maintaining the names of the parts): (works greats BUT ONLY WITH NX8 OR NX9 WHY DON'T WORKS WITH NX11 OR NX12???)
CAN SOMEBODY HELP ME? other journal?
Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
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 tags as new ArrayList
Dim strParasolid As String
lw.Open
strParasolid = workPart.FullPath
strParasolid = Left(strParasolid, Len(strParasolid) - 4)
strParasolid = strParasolid & ".x_t"
myResponse = SelectObjects(mySelectedObjects)
if (myResponse = Selection.Response.Cancel) OrElse (myResponse = Selection.Response.Back) then
'user canceled selection, exit journal
exit sub
end if
For each obj as Body in mySelectedObjects
if obj.IsOccurrence then
obj.SetName(obj.OwningComponent.DisplayName)
else
obj.SetName(obj.OwningPart.Leaf)
end if
tags.Add(obj.Tag)
Next
tagList = CType(tags.ToArray(GetType(NXOpen.Tag)), NXOpen.Tag())
ufs.Ps.ExportData(tagList, strParasolid)
lw.WriteLine("Output file: " & strParasolid)
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_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
I usually work with this journal to export from NX to parasolid (all the ensemble with all the parts,maintaining the names of the parts): (works greats BUT ONLY WITH NX8 OR NX9 WHY DON'T WORKS WITH NX11 OR NX12???)
CAN SOMEBODY HELP ME? other journal?
Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
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 tags as new ArrayList
Dim strParasolid As String
lw.Open
strParasolid = workPart.FullPath
strParasolid = Left(strParasolid, Len(strParasolid) - 4)
strParasolid = strParasolid & ".x_t"
myResponse = SelectObjects(mySelectedObjects)
if (myResponse = Selection.Response.Cancel) OrElse (myResponse = Selection.Response.Back) then
'user canceled selection, exit journal
exit sub
end if
For each obj as Body in mySelectedObjects
if obj.IsOccurrence then
obj.SetName(obj.OwningComponent.DisplayName)
else
obj.SetName(obj.OwningPart.Leaf)
end if
tags.Add(obj.Tag)
Next
tagList = CType(tags.ToArray(GetType(NXOpen.Tag)), NXOpen.Tag())
ufs.Ps.ExportData(tagList, strParasolid)
lw.WriteLine("Output file: " & strParasolid)
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_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