×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NXOpen .Net - MeasureBodies performace very poor

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

RE: NXOpen .Net - MeasureBodies performace very poor

Try the following journal. I run code like this often on small to mid size injection molded parts. Some parts make extensive use of freeform modeling techniques and I have yet to see anything take longer than 30 seconds or so.

CODE

Option Strict Off  
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

(OP)
Thanks for the script to compare my code against. I was using a near copy of what you put down, but couldn't figure out the low performance. Turns out that I had my material density set to 0, which is what caused the massive performance hit. I switched it to 0.0375 as you had, and performance increased ten-fold.

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
            }

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources