Showing results for 
Search instead for 
Do you mean 
Reply

Journal to change cut direction contour profile sequence

Hi All,
I modified journal to change cut direction from climb to convetional for planar, face milling, cavity milling and hole milling etc. from sample journal which works great but I am unable to create journal for fixed contours and contour profile (multi axis) etc. like surface ops.  Any of you guys have like this journal or reference journals could you please share with me.

Regards,
Ganesh
NX 8.5 and Vericut 7.3
20 REPLIES

Re: Journal to change cut direction contour profile sequence

This is a known problem - logged as PR# 7329736. 

It is under investigation.

 

Mark Rief
Retired Siemens

Re: Journal to change cut direction contour profile sequence

Thanks Mark,

Is there any way to check the status of PR# 7329736.

 

 

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Journal to change cut direction contour profile sequence

You can only check problem reports that you have reported and there is no progress available.

 

For your initial question, you can use the of user function wrappers to overcome any problem you encounter with the builders.

 

You need to change the code below to work in your code environment.

 

'change cut direction to counter-clockwise
'0 ... undefined (what to use in this case ???)
'1 ... clockwise
'2 ... counter-clockwise
'3 ... forward
'4 ... reverse
'5 ... mixed
Dim CurrentDirection As Integer
Const REGION_CUT_DIRECTION_TYPE As Integer = 305

Try
    UFSes.Param.AskIntValue(tOperation, UFConstants.UF_PARAM_CUT_DIR_TYPE, CurrentDirection)
    
    If CurrentDirection = 1 or CurrentDirection = 2 Then
        UFSes.Param.SetIntValue(tOperation, UFConstants.UF_PARAM_CUT_DIR_TYPE, ChangeCutDirection(CurrentDirection))
    Else
        UFSes.Param.AskIntValue(tOperation, REGION_CUT_DIRECTION_TYPE, CurrentDirection)
        
        If CurrentDirection = 1 or CurrentDirection = 2 Then
            UFSes.Param.SetIntValue(tOperation, REGION_CUT_DIRECTION_TYPE, ChangeCutDirection(CurrentDirection))
        End If
    End If
Catch e As Exception
    Ses.LogFile.WriteLine(e.Message)
End Try

 

You also need the following custom functions.

The first one is to check the current setting, the second one is to change from CW to CCW.

 

Private Function CheckCutDirection(CutDir As Integer) As String
    Select Case CutDir
        Case 0
            Return "Undefined"
        Case 1
            Return "Clockwise"
        Case 2
            Return "Counter-Clockwise"
        Case 3
            Return "Forward"
        Case 4
            Return "Reverse"
        Case 5
            Return "Mixed"
        Case Else
            Return "N/A"
    End Select
End Function

Private Function ChangeCutDirection(CutDir As Integer) As Integer
    Select Case CutDir
        Case 1
            Return 2
        Case 2
            Return 1
        Case 3
            Return 4
        Case 4
            Return 3
        Case Else
            Return 0
    End Select
End Function

 

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 to change cut direction contour profile sequence

Hi Stefan,

I adopted your program to my program, I am getting erroe while executing here is my code and i am using Nx8.5

 

'=============================================================================
'
'   Copyright 2015 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
'
'=============================================================================
'  REVISIONS

'     05-mar-2015  Mark Rief  adapt for cut direction 
' 	 19-mar-2015  Ganesh Kothakota modified for surface contour
'
' ===========================================================================
'   DESCRIPTION

'     This program will edit Surface Contour type mill operations
'
'     This can be used as a boiler plate to set other method parameters.
' ============================================================================
 
Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities

Module Cutdirection_change

    Dim theSession As Session
    Dim theUfSession As UFSession


    Sub Main()

        theSession = Session.GetSession()
        theUfSession = UFSession.GetUFSession()
		Dim UFSes As UFSession = UFSession.GetUFSession()
		Dim UISes As UI        = UI.GetUI()

        Dim WorkPart As Part = TheSession.Parts.Work

        Dim setupTag As Tag
        Dim camObjectTag As Tag
        Dim selectedTags() As NXOpen.Tag
        Dim selectedCount As Integer

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

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

            ' Get the selected nodes from the Operation Navigator
            theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)

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

            Dim i As Integer
            'Loop over the selected nodes to take action
            For i = 0 To selectedCount - 1
                ' The selected item needs to be checked to take action
                action(selectedTags(i))
                ' Now if the selected item is a Group object then we need to cycle objects inside it
                theUfSession.Ncgroup.CycleMembers(selectedTags(i), cycle_cb_fn, ptr)
            Next i
        End If

    End Sub


    Function cycle_cb(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean

        Dim answer As Boolean
        ' Every item needs to be checked to take action
        answer = action(camObjectTag)
        Return answer

    End Function

    Function action(ByVal camObjectTag As Tag) As Boolean

        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)
        Dim WorkPart As Part = TheSession.Parts.Work
		
        'Check if the object is an Operation
        If TypeOf camObject Is CAM.Operation Then
            Dim operationType As Integer
            Dim operationSubtype As Integer

            'Get the type and subtype of the operation
            theUFSession.Obj.AskTypeAndSubtype(camObjectTag, operationType, operationSubtype)
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("operationSubtype = " & operationSubtype)

            Dim operationBuilder As CAM.MillOperationBuilder
		 		
			
           If operationSubtype = 210 Then         ' This is a Fixed Axis Surface Contour Operation so create a Surface Contour Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
  		ElseIf operationSubtype = 266 Then         ' This is a Variable Axis Z Level Milling Operation so create a Variable Axis Z Level Milling Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateVazlMillingBuilder(camObject)
     		ElseIf operationSubtype = 211 Then         ' This is a Variable Axis Surface Contour Operation so create Surface Contour Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
				

	
           End If

           
	' Check if there is a valid Builder FOR SURFACE CONTOUR
            If  operationBuilder IsNot Nothing Then
	'change cut direction to counter-clockwise
	'0 ... undefined (what to use in this case ???)
	'1 ... clockwise
	'2 ... counter-clockwise
	'3 ... forward
	'4 ... reverse
	'5 ... mixed
	Dim CurrentDirection As Integer
	Const REGION_CUT_DIRECTION_TYPE As Integer = 305

		Try
   		 UFSes.Param.AskIntValue(camObject, UFConstants.UF_PARAM_CUT_DIR_TYPE, CurrentDirection)
    
    		If CurrentDirection = 1 or CurrentDirection = 2 Then
        		UFSes.Param.SetIntValue(camObject, UFConstants.UF_PARAM_CUT_DIR_TYPE, ChangeCutDirection(CurrentDirection))
   		 Else
        		UFSes.Param.AskIntValue(camObject, REGION_CUT_DIRECTION_TYPE, CurrentDirection)
        
       		 If CurrentDirection = 1 or CurrentDirection = 2 Then
            	UFSes.Param.SetIntValue(camObject, REGION_CUT_DIRECTION_TYPE, ChangeCutDirection(CurrentDirection))
        End If
    End If
Catch e As Exception
    Ses.LogFile.WriteLine(e.Message)
End Try
      		
			
                'Commit the change to the operation( this is the equivalent of OK'ing the operation dialog )
                operationBuilder.Commit()

                'Destroy the builder its job is done(clean up memory)
                operationBuilder.Destroy()

				' Comment the following two lines to suppress the listing window
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("Parameters set in: " & camObject.Name() )
				  			
			
				
            End If
 End If

        Return True
    End Function
Private Function CheckCutDirection(CutDir As Integer) As String
    Select Case CutDir
        Case 0
            Return "Undefined"
        Case 1
            Return "Clockwise"
        Case 2
            Return "Counter-Clockwise"
        Case 3
            Return "Forward"
        Case 4
            Return "Reverse"
        Case 5
            Return "Mixed"
        Case Else
            Return "N/A"
    End Select
End Function

Private Function ChangeCutDirection(CutDir As Integer) As Integer
    Select Case CutDir
        Case 1
            Return 2
        Case 2
            Return 1
        Case 3
            Return 4
        Case 4
            Return 3
        Case Else
            Return 0
    End Select
End Function
End Module

 

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Journal to change cut direction contour profile sequence

First you need to read the NXOpen .NET API reference to be able to change the code to fit into your source code, without that you will never succeed.

 

The error displayed is usually telling you what is wrong, so you will just have to connect the error with the description of the API function.

 

A journal is a fully blown VB.NET source code, so you need to spend time on learning VB.NET to some extend to get things working.

Without a foundation you will always be lost.

 

The old UF wrappers always need tags and not objects, this is described in the descriptions of the methods in the NX Open .NET API reference, so read them.

You don't have the object UFsess, it is called differently in your source code, so you need to use your definition of the UFSession object too.

Again a firm understanding of coding in VB.NET is a must for automation through journals.

 

Best is to use a VB.NET IDE (code editor) with all the bells and whistles to help you correct your errors, a regular text editor is not useful if you are not fluent in VB.NET.

In addition it offers code completion, hints and suggestions, SharpDevelop is a free one.

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 to change cut direction contour profile sequence

Yes, I am new to this jornal programming and I am trying to learning. I will go through as you suggested, thanks for your valuable information. Is possible to make this journal executable so I can used this as reference for my future projects, if possible

 

Regards,

Gani

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Journal to change cut direction contour profile sequence

I know that you are new and that there is much to learn, I just wanted to make sure that you don't "insist" on getting spoon feed, but take the chance to learn how to do it on your own Smiley Wink

 

You need to do the following:

  1. Replace UFSes with theUfSession
  2. Replace tOperation with camObjectTag
  3. Replace Ses with theSession

There is no need to define the same object twice, it just makes the program use more memory.

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 to change cut direction contour profile sequence

Hi Stefan

Thanks for your support.I will start learning on back end of vb.net.

 

 I updated code as you suggested, it's running with error free but when it executed my cut direction is not changing still its same (climb). I tried for contour profile

 

Also I am trying to download sharp tool develop. but I got confusion which version am i need to download. Please suggest

I am using Windows 7 ultimate with .net framework 4.5.2

 

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Journal to change cut direction contour profile sequence

SharpDevelop v4 is the current stable release and what I use too.

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

Learn online





Solution Information