Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Nx Journaling - Get Full path of Selected component 1

Status
Not open for further replies.

Kumaresh_07

Automotive
Joined
Jul 21, 2019
Messages
14
Location
IN
hi all,

I would like to write a code for Getting Full path of Selected component.
It would be nice if you guys could help me.
Now i have code for user component selection. but i don't know how to get that selected component directory.


Code:
Option Explicit Off
Option Infer On

Imports NXOpen
Imports System
Imports NXOpen.UF

Module NXJournal

    Sub Main()

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

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select the component"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple

        With selectionMask_array(0)
            .Type = UFConstants.UF_component_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)

    End Sub

End Module
 
Try this:

Code:
Option Explicit Off
Option Infer On

Imports NXOpen
Imports System
Imports NXOpen.UF

Module NXJournal

    Sub Main()

        Dim theSession = NXOpen.Session.GetSession()
        Dim workPart As NXOpen.Part = theSession.Parts.Work
        Dim displayPart As NXOpen.Part = theSession.Parts.Display
	Dim prtName As String 
	Dim prtNameAndPath As String
	
	Dim lw As ListingWindow = theSession.ListingWindow
      
	Dim theUI As UI = UI.GetUI

	lw.open()

        Dim title As String = "Select the component"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple

        With selectionMask_array(0)
            .Type = UFConstants.UF_component_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)

	If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
	
		Return
		
	End If

	lw.writeline(selobj.OwningPart.FullPath)


	lw.close()

    End Sub

End Module

With best regards
Michael
 
Wow.. It works in perfect manner.
Thanks Michael.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top