NXOpen .Net - MeasureBodies performace very poor
NXOpen .Net - MeasureBodies performace very poor
(OP)
I've been working on a program to compute minimum part boxes, as well the the overall part volume/area/weight. The GRIP function (ANLSIS/SOLID) that pulled volume/area/weight was fairly quick, but the current MeasureBodies and AskPartProps3d speed is glacial!
Complex parts with many holes and swept features can take as long as 5 minutes to analyze, while the similar GRIP function completes in a fraction of this. Is there any reason behind this? I've tried reducing the accuracy of the MeasureBodies to as low as 0.1, but it still performs poorly and values that in accurate defeat the purpose of the measurements.
Bruce
Complex parts with many holes and swept features can take as long as 5 minutes to analyze, while the similar GRIP function completes in a fraction of this. Is there any reason behind this? I've tried reducing the accuracy of the MeasureBodies to as low as 0.1, but it still performs poorly and values that in accurate defeat the purpose of the measurements.
Bruce





RE: NXOpen .Net - MeasureBodies performace very poor
CODE
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
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 bbox(5) as double
Dim dblAcc_Value(11) as double
Dim dblMass_Props(46) as double
Dim dblStats(12) as double
dim strOutput as string
Dim solid1 As Body = SelectSolid()
If solid1 Is Nothing Then
Return
End If
Dim tagList(0) As NXOpen.Tag
tagList(0) = solid1.Tag
'get volume
dblAcc_Value(0)=.999
'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)
strOutput = "Surface Area: " & dblMass_Props(0) & vbcrlf
strOutput = strOutput & "Volume: " & dblMass_Props(1) & vbcrlf
strOutput = strOutput & "Mass: " & dblMass_Props(2) & vbcrlf
strOutput = strOutput & "COG: " & dblMass_Props(3) & ", " & dblMass_Props(4) & ", " & dblMass_Props(5) & vbcrlf
strOutput = strOutput & "Density: " & dblMass_Props(46)
msgbox (strOutput, vbokonly)
'get solid body bounding box extents
ufs.Modl.AskBoundingBox(solid1.Tag,bbox)
msgbox ("min X: " & bbox(0) & " max X: " & bbox(3) & vbcrlf _
& "min Y: " & bbox(1) & " max Y: " & bbox(4) & vbcrlf _
& "min Z: " & bbox(2) & " max Z: " & bbox(5) & vbcrlf & vbcrlf & _
"X dim: " & bbox(3) - bbox(0) & vbcrlf & _
"Y dim: " & bbox(4) - bbox(1) & vbcrlf & _
"Z dim: " & bbox(5) - bbox(2), vbokonly)
End Sub
'**********************************************************
Public Function SelectSolid() As Body
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
Dim selectedObject As NXObject = Nothing
Dim cursor As Point3d
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
'.SolidBodySubtype = 36
End With
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
Return Nothing
End If
Return solid
End Function
'*******************
End Module
www.nxjournaling.com
RE: NXOpen .Net - MeasureBodies performace very poor
Thanks for the help! Here's the function i was using(its in c#) for anyone referencing this.
public void GetPartProps(NXObject NO)
{
double[] acc_value = new double[11];
double[] mass_props = new double[47];
double[] stats = new double[13];
acc_value[0] = 0.9;
Tag[] NOtag = new Tag[1] { NO.Tag };
_UFSession.Modl.AskMassProps3d(NOtag, 1, 1, 1, 0.0375, 1, acc_value, mass_props, stats);
//access mass_props[] to retrieve values
}