cancel
Showing results for 
Search instead for 
Did you mean: 

Journal for replacing tools (from library)

Creator
Creator

Hi all!

I'm new to NX Open and quite new to programming.

So I have an operation in wich I want to replace a tool.
If a certain tool appears, then replace it with some other tool

We use tools retrieved from our customized library.
As far as I know, each tool has it's number, I figured that out by using

Dim ToolCollection As CAM.Tool = operation.GetParent(CAMSetup.View.MachineTool) 
Guide.InfoWriteLine(ToolCollection.ToString)

Each tool returns a different value, something like:

Tool 100973


So I guess this is the parameter to operate with, because tool name sometimes changes and makes journal unreliable.
So how do I do this?
And how do I do the same with methods?

Thanks
Damijan

4 REPLIES

Re: Journal for replacing tools (from library)

I do not understand the number you are getting for the tool parent. You can get the name:

   Dim toolName As String
   toolName = operation.GetParent(CAMSetup.View.MachineTool)

This should also work:

Dim ToolGroup as NCGroup = myOp.GetParent(CAMSetup.View.MachineTool)
Dim GroupName as String = ToolGroup.Name 

How do you identify the tool to be replaced? If it is always a library tool, you can check the libref. I am thinking you would check the work part for a tool with the libref, and if it is not found, retrieve it from the library, and assign it as tool parent for the operation.

It would be easier to rely on the names, but there is a problem if your users rename or edit library tools. 

Mark Rief
Retired Siemens

Re: Journal for replacing tools (from library)

Esteemed Contributor
Esteemed Contributor

Since you are talking about library tools use the LibRef, which is unique by default, the name can be changed, so can many other things.

Below find a function to get the library reference, which you should use in this situation.

    Private Function GetCutterLibRef(theCutter As CAM.NCGroup) As String
        GetCutterLibRef = ""
        
        Try
            GetCutterLibRef = theCutter.GetStringValue("Cutter Libref")
        Catch ex As Exception
            theSession.LogFile.WriteLine("GetCutterLibRef: failed to check LibRef for " & theCutter.Name)
        End Try
        Try
            If String.IsNullOrEmpty(GetCutterLibRef) Then
                theUFSession.Param.AskStrValue(theCutter.Tag, 1085, GetCutterLibRef)
            End If
        Catch ex As Exception
            theSession.LogFile.WriteLine("GetCutterLibRef: failed to check previous LibRef for " & theCutter.Name)
        End Try
    End Function

This function first tries to get the library reference, which in rare cases can get lost, but then there is the previous library reference.

Only if both are empty, then the tool is no library tool.

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: Journal for replacing tools (from library)

Creator
Creator

I guess the best way to do it is with LibRef.
I got it working, I just have to edit my code further.
Thanks guys, just one more thing Stefan, I don't understand 1085 parameter from this line

 theUFSession.Param.AskStrValue(theCutter.Tag, 1085, GetCutterLibRef)

 

Re: Journal for replacing tools (from library)

Esteemed Contributor
Esteemed Contributor

It is the numerical ID of the previous library reference parameter.

The UF wrapper functions are working differently, since they have been written in C initially.

Some CAM object parameters can be accessed with the new managed methods and the parameters name, but some need to be accessed through their numerical ID.

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