×
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

FindObject("PROTO#.Bodies *** in Journal VB

FindObject("PROTO#.Bodies *** in Journal VB

FindObject("PROTO#.Bodies *** in Journal VB

(OP)
Hi

I´m writing on a little script , that will help me get quicker starting on a new EDM electrode part.

I use the the "Create New Parent" to create an assembly,
and the Electrode part will be the top part - and the core and cavity plate is the component.
I have made som VB tricks to automate the new name of the Electrode part. Everything works fine - but I have one problem.

In the new part I want to make a Linked Body of the component´s solid body (core or cavity plate).

In the recorded journal I have edited the "COMPONENT CavityPlatePart 1" so it is a variable of the component name.
That works 100%.
 
recorded journal :
>> Dim component1 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT CavityPlatePart 1"), Assemblies.Component) <<

But, and here comes the problem.

recorded journal :
>> Dim body1 As Body = CType(component1.FindObject("PROTO#.Bodies|EXTRUDE(1)"), Body) <<

I can´t get a solution to create a variable of the component´s Solid Body name, so I can replace the EXTRUDE(1) in ("PROTO#.Bodies|EXTRUDE(1)"), with a variable.

Maybe someone here can the trick ?

lklo



 

RE: FindObject("PROTO#.Bodies *** in Journal VB

I often apply a name to a body so that it becomes a simple journal/program task to find the body.  The small example code finds and highlights a body that has the name WHATEVER applied to it.

Option Strict Off
Imports System
Imports NXOpen

Module FindNamedObject
    Sub Main()
        Dim s As Session = Session.GetSession()
        Dim workPart As Part = s.Parts.Work
        Dim bodies As BodyCollection = workPart.Bodies
        Dim bodyname As String = "WHATEVER"

        For Each b As Body In bodies
            If Not b.IsBlanked Then
                If b.Name = bodyname Then
                    b.Highlight()
                End If
            End If
        Next
    End Sub

Just change the bodyname string to whatever you might apply to the required body.

Hope this helps.

Frank Swinkels

RE: FindObject("PROTO#.Bodies *** in Journal VB

(OP)
Hello Frank

Thank You for the answer.

But your solution in my case is not what I need.



I need to be able to create a linked body of the displayed componet( always a solid body on layer 1).

I can get the component in a variable.But not the body.

I have tried with the command  DisplayableObject
but I cant figure it out.

lklo
 

RE: FindObject("PROTO#.Bodies *** in Journal VB

OK for an assembly it is better to use object cycle by name as in the simple journal/program below.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Utilities
Imports NXOpen.UF

Module FindNamedObject
    
    Sub Main()
        Dim s As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()

        Dim bodyname As String = "WHATEVER"
        Dim obj As Body
        Dim objTag As Tag = Tag.Null

        ufs.Obj.CycleByName(bodyname, objTag)
        If objTag <> Tag.Null Then
            obj = NXObjectManager.Get(objTag)
            obj.Highlight()
        End If

    End Sub

    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

Hope this helps.

Frank Swinkels

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