Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Journal - Find Parent Part 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
I have selected an edge and I have the object tag. How do I find out what the name of the parent part is using NX Journal?

I'm thinking something like:
Code:
Dim part1 As Part = CType(theSession.Parts.FindObject(edge.ToString), Part)

But this doesn't work.

Help!
Thanks,
Jeff
 
Replies continue below

Recommended for you

Here is a quick journal that allows you to select an edge then lists various properties of the edge including the parent part.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

Dim lw As ListingWindow = theSession.ListingWindow
Dim myEdge as Edge

		If (SelectEdge(myEdge) = Selection.Response.ObjectSelected) Then
			lw.Open
			lw.WriteLine(myEdge.ToString)
			lw.WriteLine("Owned by Part: " & myEdge.OwningPart.FullPath)
			if myEdge.IsOccurrence then
				lw.WriteLine("Owned by Component: " & myEdge.OwningComponent.Name)
				lw.WriteLine("Component Part Path: " & myEdge.Prototype.OwningPart.FullPath)
			end if
			lw.WriteLine("")
			lw.WriteLine("Edge properties")
			if myEdge.Name = "" then
				lw.WriteLine("Name: <NONE>")
			else
				lw.WriteLine("Name: " & myEdge.Name)
			end if
			lw.WriteLine("Color: " & myEdge.Color)
			lw.WriteLine("Length: " & myEdge.GetLength)
			lw.WriteLine("Layer: " & myEdge.Layer)
			lw.WriteLine("LineFont: " & myEdge.LineFont.ToString)
			lw.WriteLine("LineWidth: " & myEdge.LineWidth.ToString)
			lw.WriteLine("SolidEdgeType: " & myEdge.SolidEdgeType.ToString)
			lw.WriteLine("")
			lw.Close
		Else
			lw.Open
			lw.WriteLine("Selection cancelled")
			lw.WriteLine("")
			lw.Close
		End If


lw.WriteLine(myEdge.ToString)


End Sub

    Function SelectEdge(ByRef selectedObject As NXObject) As Selection.Response

        Dim ui As UI = ui.GetUI()
        Dim title As String = "Select an Edge"
        Dim response As Selection.Response
        Dim selectionMask(0) As Selection.MaskTriple
        With selectionMask(0)
            .Type = UFConstants.UF_solid_type
            .Subtype = UFConstants.UF_solid_body_subtype
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
        End With
        Dim cursor As Point3d = Nothing

        response = ui.SelectionManager.SelectObject("Select an Edge", _
            "Select an Edge", Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, selectionMask, selectedObject, cursor)

        Return response

    End Function

End Module
 
Thanks, I used:

Code:
Dim part1 As Part = CType(theSession.Parts.FindObject(curvObj.Prototype.OwningPart.FullPath), Part)

Based on yours. It works great!

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor