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
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
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
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
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