cancel
Showing results for 
Search instead for 
Did you mean: 

Tool - UG Type

Valued Contributor
Valued Contributor

Hi,

 

Is there a way to get the UG Type and the UG Subtype of a tool?

cover.jpg
(tool_database.dat)

 

Thanks,

Tom.

4 REPLIES

Re: Tool - UG Type

Esteemed Contributor
Esteemed Contributor

The cutter types and sub-types are defined in %UGII_BASE_DIR%\UGOPEN\uf_cutter.h and you should be able to use the function UF_CUTTER_ask_type_and_subtype or its wrapper to get them.

Don't know if these are exposed to MOM/Tcl.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Tool - UG Type

Valued Contributor
Valued Contributor

Thank you for your answer.

I did it, but I get only numbers and not the names. I guess it's an Enum value.

Is there a way to convert it to the matching name?

 

EDIT:

I did it like this:

AskTypeAndSubtypeData a = UFSession.cutter().askTypeAndSubtype(operationTool.tag());
System.out.println(Tool.Types.valueOf(a.type));

System.out.println(Tool.Subtypes.valueOf(a.subtype));

 

I hope It's like it should.

Re: Tool - UG Type

Esteemed Contributor
Esteemed Contributor

With the defines listed in UGOPEN\uf_cutter.h, you can convert the numbers into names on your own.

You can use a switch statement to check against the UFConstants.UF_CUTTER_TYPE_... and UF_CUTTER_SUBTYPE_... values.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Tool - UG Type

This vb journal lists the type and sybtype of all tools in the part

' ToolInfoTypeSubtypeCycleAll.vb
'   DESCRIPTION
    ' This program will cycle through all the tools in the part and 
	' list the type and subtype.
' ============================================================================

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

Module Tools

    Dim theSession As Session
    Dim theUfSession As UFSession
	
    Sub Main()

        theSession = Session.GetSession()
        theUfSession = UFSession.GetUFSession()
        Dim WorkPart As Part = TheSession.Parts.Work

        Dim setupTag As Tag
        Dim camObjectTag As Tag
        Dim mctRootTag As Tag

        theUfSession.Cam.InitSession()
        theUfSession.Setup.AskSetup(setupTag)

        ' If there is a setup only then do we have to go further
        If setupTag <> 0 Then

            Dim ptr As IntPtr = New System.IntPtr
            Dim cycle_cb_fn As UFNcgroup.CycleCbFT = New UFNcgroup.CycleCbFT(AddressOf cycle_cb)

            ' Get the Machine Tool View's Root
            theUfSession.Setup.AskMctRoot(setupTag, mctRootTag)

			Dim output As String = String.Format("{0, -32} {1, -5} {2, -10}", "Tool Name", "Type", "Subtype")
			theSession.ListingWindow().Open
			theSession.ListingWindow().WriteLine(output)
			
            If mctRootTag <> 0 Then
                'Cycle through the Machine Tool View and find every object 
                theUfSession.Ncgroup.CycleMembers(mctRootTag, cycle_cb_fn, ptr)
            End If

        End If

    End Sub

    'This is the function that is called on every object encountered in the cycling
    Function cycle_cb(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean

        Dim answer As Boolean
        Dim WorkPart As Part = TheSession.Parts.Work

        ' When cycling check if the obejct is a Group
        theUfSession.Ncgroup.IsGroup(camObjectTag, answer)

        ' Only then we need to do something
        If answer = True Then
		
	        ' Find the cam object from the Tag
	        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)

	        'Check if the object is a Tool
	        If TypeOf camObject Is CAM.Tool Then

	            Dim cutterType As Integer
	            Dim cutterSubtype As Integer
	            theUFSession.Cutter.AskTypeAndSubtype(camObjectTag, cutterType, cutterSubtype)

				Dim output As String = String.Format("{0, -32} {1, -5} {2, -10}", camObject.Name(), cutterType.ToString(), cutterSubtype.ToString())
				theSession.ListingWindow().WriteLine(output)
				
	        End If
			
        End If

        Return True
    End Function

End Module

Mark Rief
Retired Siemens