×
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

NX Open .NET identifying faces in FEM

NX Open .NET identifying faces in FEM

NX Open .NET identifying faces in FEM

(OP)
Is there anyone who has experience of NX OPEN in NX7.5?

I'm trying to construct a script that will identify geometry such as faces and edges according to attributes (colour etc). The following works in 'Modelling' but I have come unstuck when trying the equivalent in 'Advanced Simulation'

Dim edge_1 As NXOpen.Edge
Dim point_1 As NXOpen.Point
Dim b As NXOpen.Part = workPart
For Each c As NXOpen.Body In b.Bodies
For Each d As NXOpen.Face In c.GetFaces
Dim e As Integer = d.Color
If e = 20 Then
For Each f As NXOpen.Edge In d.GetEdges
edge_1 = f
Next

point_1 = workPart.Points.CreatePoint(edge_1, SmartObject.UpdateOption.WithinModeling)
point_1.SetVisibility(SmartObject.VisibilityOption.Visible)
MsgBox(point_1.Coordinates.X)
MsgBox(point_1.Coordinates.Y)
MsgBox(point_1.Coordinates.Z)
End If
Next
Next

Any help much appreciated!

RE: NX Open .NET identifying faces in FEM

With this statement:

Quote:


The following works in 'Modelling' but I have come unstuck when trying the equivalent in 'Advanced Simulation'

I suppose you meant that it does not work in the Advanced Simulation module?

Also, I am not quite sure what you are trying to achieve with:

CODE

                    For Each f As NXOpen.Edge In d.GetEdges
                        edge_1 = f
                    Next

I'm guessing you are trying to print out the coordinates of each edge whose color is 20? In that case, you should try push this code in the for-loop:

CODE

                    point_1 = workPart.Points.CreatePoint(edge_1, SmartObject.UpdateOption.WithinModeling)
                    point_1.SetVisibility(SmartObject.VisibilityOption.Visible)
                    MsgBox(point_1.Coordinates.X)
                    MsgBox(point_1.Coordinates.Y)
                    MsgBox(point_1.Coordinates.Z)

So that it reads:

CODE

                    For Each f As NXOpen.Edge In d.GetEdges
                        point_1 = workPart.Points.CreatePoint(f, SmartObject.UpdateOption.WithinModeling)
                        point_1.SetVisibility(SmartObject.VisibilityOption.Visible)
                        MsgBox(point_1.Coordinates.X)
                        MsgBox(point_1.Coordinates.Y)
                        MsgBox(point_1.Coordinates.Z                        
                    Next

With your current code, it will only report the information of the last edge, and not all of them.

RE: NX Open .NET identifying faces in FEM

(OP)
Thanks MarckyMON,

You suppose correctly that it is the Advanced Simulation module for which I would like the equivalent result.

You are also right in that the code would return results for the last entry only.  At present I am only testing a proof of concept, and there is only one face whose colour value is equal to 20, so this is not too much of a concern.

The assistance I would welcome would be the equavalent results for CAE faces & edges in Advanced Simulation, since I can't figure out the hierarchy of NXObjects that would allow me to extract/ identify the features I'm interested in.
 

RE: NX Open .NET identifying faces in FEM

Can you maybe elaborate what is not exactly working? Is the script abruptly ending with an exception? Are any edges found at all?

You can use the listing window as a debugging tool.

Marc
NX Software Developer
 

RE: NX Open .NET identifying faces in FEM

(OP)

Sorry - maybe I should elaborate on the process I'm trying to achieve.  Maybe my entire approach could be more efficient...

Ultimately I am trying to identify polygon faces and points within a FEM model that contains multiple CAE bodies.  These features I would then reference to create 1D connector elements (RBE2 etc) in the FEM, and create simulation loads and constraints, and define contact/ glue in the SIM.

So far I have been trying to adapt journal scripts to fit my purpose, however these generally require prior knowledge of the object I am trying to identify; e.g.

        Dim cAEBody1 As CAE.CAEBody = CType(workFemPart.FindObject("CAE_Body(3)"), CAE.CAEBody)
        Dim cAEFace1 As CAE.CAEFace = CType(cAEBody1.FindObject("CAE_Face(1932)"), CAE.CAEFace)

This would return the face I am interested in as the value of cAEFace1.

The area I am struggling with is an alternative method to identify this face.  In the Modelling module I achieved this with the (not very elegant) code above.  When I try to adopt a similar approach in Advanced Simulation module, I cannot find the equivalent members & methods of the CAE objects.

For example, in the following code:

        Dim theSession As Session = Session.GetSession()
        Dim workFemPart As CAE.FemPart = CType(theSession.Parts.BaseWork, CAE.FemPart)
        Dim displayFemPart As CAE.FemPart = CType(theSession.Parts.BaseDisplay, CAE.FemPart)
        Dim femPart1 As CAE.FemPart = CType(workFemPart, CAE.FemPart)

        For Each CAEBody1 As CAE.CAEBody In femPart1. ...


There is no member or method for 'femPart1' that would allow me to search through each body, and then each face within that body so that I could try to match it against a criteria (e.g. colour)

I have had some success with searching objects using:

        theUfSession.Obj.CycleObjsInPart

however I can only return tags, and nothing I can use subsequently.

I have only recent exposure to NX Open, and therefore find it hard to navigate the documentation to find the information I am searching for.

Again, any assistance would be greatly appreciated!

RE: NX Open .NET identifying faces in FEM

(OP)
also, you mentioned the listing window.
I've not come across this before - is there anywhere I can find out more info about how to use this?

Is it an NX feature or inherent to .net?

Thanks for your help so far

RE: NX Open .NET identifying faces in FEM

(OP)

Problem Solved, Thanks for assistance in the meantime!


CODE

        Dim basePart As BasePart = theSession.Parts.BaseWork
        Dim baseFEMPart As CAE.BaseFemPart = CType(basePart, CAE.BaseFemPart)
        Dim baseFEModel As CAE.BaseFEModel = CType(baseFEMPart.BaseFEModel, CAE.BaseFEModel)


        Dim NULLTAG As Tag = NXOpen.Tag.Null
        Dim objectTag As Tag = NXOpen.Tag.Null

        theUfSession.Obj.CycleObjsInPart(baseFEMPart.Tag, NXOpen.UF.UFConstants.UF_caegeom_type, objectTag)


        Do

            Dim objType As Integer = 0
            Dim objSubtype As Integer = 0
            Dim objectName As String = Nothing
            Dim myBody As Body = Nothing
            Dim myCAEBody As CAE.CAEBody = Nothing
            Dim myObject As NXObject = Nothing
            Dim myMaterial As String = Nothing
            Dim GroupObjects() As NXOpen.TaggedObject = Nothing

            theUfSession.Obj.AskTypeAndSubtype(objectTag, objType, objSubtype)

            If objSubtype = NXOpen.UF.UFConstants.UF_caegeom_body_subtype Then

                myObject = NXObjectManager.Get(objectTag)
                myCAEBody = CType(myObject, CAE.CAEBody)

                MsgBox("Tag = " & objectTag & ", Name = " & myCAEBody.JournalIdentifier)
            End If

            theUfSession.Obj.CycleObjsInPart(basePart.Tag, NXOpen.UF.UFConstants.UF_caegeom_type, objectTag)

        Loop While objectTag <> NULLTAG

 

RE: NX Open .NET identifying faces in FEM

Petewirth,

The listing window is an NX feature.

For the NX listing window to be used for output it has to be "opened" with the following...

     theSession.ListingWindow.Open()

Typically this is done once at the beginning of the program.

Then just as you had used messagebox you can construct the output string and send it to the NX listing window where it is appended to any exisitng output there.

    theSession.ListingWindow.WriteLine("Tag = " & objectTag & ", Name = " & myCAEBody.JournalIdentifier)

(word wrap warning!) The example above is one line.

The net_ref.chm (from the t-doc "Automation,NX Open,NX Open for .NET Reference Guide") explains the available methods an properties for ListingWindow.
 
Regards, Joe

RE: NX Open .NET identifying faces in FEM

(OP)

Nice - Thanks Joe!

Pete

 

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