' NX 6.0.0.24
'
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies
Imports System.IO
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 strPart as string
Dim pos as integer
Dim bbox(5) as double
Dim dblAcc_Value(11) as double
Dim dblMass_Props(46) as double
Dim dblStats(12) as double
'''msgbox ("inizio")
Dim solid1 As Body = SelectSolid()
If solid1 Is Nothing Then
Return
End If
Dim tagList(0) As NXOpen.Tag
tagList(0) = solid1.Tag
'get the full file path
strPart = solid1.owningpart.fullpath
'''msgbox(strPart)
pos = InStrRev(strPart, "\")
'strip off the ".prt" extension
strPart = Left(strPart, Len(strPart) - 4)
'''msgbox(strPart)
'add extension to file name for parasolid export
strPart = strPart + ".x_t"
'''msgbox ("tag: " & solid1.Tag, vbokonly, "Tag")
'''msgbox ("file: " & strPart, vbokonly, "Part")
'export the solid to a parasolid file
'ufs.Ps.ExportData(tagList, strPart)
'get volume
dblAcc_Value(0)=.999
''' ufs.Modl.AskMassProps3d(in_Tags(),in_num_objs,in_type,in_units, _
in_density,in_accuracy,in_accuracy_values(),out_mass_props(),out_stats())
''' ufs.Modl.AskMassProps3d(tagList,1,1,1,.0375,1,dblAcc_Value(), _
dblMass_Props(),dblStats())
ufs.Modl.AskMassProps3d(tagList,1,1,1,.0375,1,dblAcc_Value, _
dblMass_Props,dblStats)
msgbox ("Volume: " & dblMass_Props(1), vbokonly)
'get solid body bounding box extents
ufs.Modl.AskBoundingBox(solid1.Tag,bbox)
msgbox ("min X: " & bbox(0) & "min Y: " & bbox(1) & "min Z: " & bbox(2) & "max X: " & bbox(3) & "max Y: " & _
bbox(4) & "max Z: " & bbox(5), vbokonly)
End Sub
Public Function SelectSolid() As Body
'''msgbox("passato a solid")
Dim ui As UI = ui.GetUI
Dim message As String = "Select solid body"
Dim title As String = "Selection"
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim keepHighlighted As Boolean = False
Dim includeFeatures As Boolean = True
Dim selectionAction As Selection.SelectionAction = _
Selection.SelectionAction.ClearAndEnableSpecific
Dim selectionMask_array(1) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
'.SolidBodySubtype = 36
End With
Dim selectedObject As NXObject = Nothing
Dim cursor As Point3d
ui.SelectionManager.SelectObject(message, title, scope, _
selectionAction, includeFeatures, _
keepHighlighted, selectionMask_array, _
selectedObject, cursor)
Dim solid As Body = CType(selectedObject, Body)
If solid Is Nothing Then
'''msgbox("Return Nothing")
Return Nothing
End If
'''msgbox("Return solid")
Return solid
End Function
End Module