Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK 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
Jul 21, 2019
14
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
 
Replies continue below

Recommended for you

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

Part and Inventory Search

Sponsor