×
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

collect Solid Body from deformable feature in nx journal

collect Solid Body from deformable feature in nx journal

collect Solid Body from deformable feature in nx journal

(OP)
Hi guys -

I'm struggling a bit, when I try to collect solid bodies from current workaprt into a array (of Body) in nx journal..
I can easily collect the solid bodies created from ordinary features, but the bodies from the special featureType "FLEXED_PART",is challenge me a bit....

CODE -->

Dim bodies() As body = workpart.bodies.toarray

        For Each tmpbody As body In bodies
            nx(tmpbody.tag)
        Next 

Do any of you have tried to play with these solid bodies created from a "deformable part"- what I mean is - to collect these bodies as solid bodies...

lklo

RE: collect Solid Body from deformable feature in nx journal

You can get all the bodies in the currently displayed assembly by using the .CycleObjsInPart method.

CODE

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        lw.Open()

        Const undoMarkName As String = "report assembly bodies"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim theBodies As New List(Of Body)
        theBodies = AskAllBodies(theSession.Parts.Display)

        For Each tempBody As Body In theBodies
            lw.WriteLine("isOccurrence: " & tempBody.IsOccurrence.ToString)
            If tempBody.IsOccurrence Then
                lw.WriteLine("OwningComponent: " & tempBody.OwningComponent.DisplayName)
                lw.WriteLine("Parent: " & tempBody.OwningComponent.Parent.DisplayName)
                lw.WriteLine("isPartDeformable: " & theUfSession.Assem.IsPartDeformable(tempBody.OwningComponent.Prototype.OwningPart.Tag).ToString)

                If theUfSession.Assem.IsPartDeformable(tempBody.OwningComponent.Prototype.OwningPart.Tag) Then

                    Dim theDeformedFeatureTag As Tag = Tag.Null
                    theUfSession.Assem.AskDisplayedDeformationOfPartOcc(tempBody.OwningComponent.Tag, theDeformedFeatureTag)

                    lw.WriteLine("isDeformed in the display part: " & (Not theDeformedFeatureTag = Tag.Null).ToString)

                End If

            Else
                lw.WriteLine("OwningPart: " & tempBody.OwningPart.Leaf)
            End If



            lw.WriteLine("")

        Next

        lw.Close()

    End Sub

    Function AskAllBodies(ByVal thePart As Part) As List(Of Body)

        Dim theBodies As New List(Of Body)

        Dim aBodyTag As Tag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(thePart.Tag, _
                UFConstants.UF_solid_type, aBodyTag)
            If aBodyTag = Tag.Null Then
                Exit Do
            End If

            Dim theType As Integer, theSubtype As Integer
            theUfSession.Obj.AskTypeAndSubtype(aBodyTag, theType, theSubtype)
            If theSubtype = UFConstants.UF_solid_body_subtype Then
                theBodies.Add(Utilities.NXObjectManager.Get(aBodyTag))

            End If
        Loop While True

        Return theBodies

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module 

www.nxjournaling.com

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