Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

collect Solid Body from deformable feature in nx journal 1

Status
Not open for further replies.

lklo

Industrial
Nov 24, 2010
226
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[b][/b]

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
 
Replies continue below

Recommended for you

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor