Cancel
Showing results for 
Search instead for 
Did you mean: 

Rename Operations in Blockstyler

Valued Contributor
Valued Contributor

Hello everyone

I read some posts and the "Getting started guide for NX open" and also watched in the examples wich NX delivers.

 

So my goal would be to create a Blockstyler Dialog wich the user can choose how to rename the operations.

 

I would like to achief those values in the operation name:

-Get a sequence number

-Remove the "Copy" in the name (If we have a sequence number the operation is unique defined)

-Add the Tool axis name to every operation

 

So i started with the sequence number and the post from Mr.Pendl. 

I made a Block Styler dialog with a button and launched this as a Journal.

I added this to the "update_cb"

                Dim theSession As Session = Session.GetSession()
                Dim theUFSession As UFSession = UFSession.GetUFSession()
                Dim theUI As UI = UI.GetUI()
                Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")
                Dim UGRelease As String = Nothing
                Dim UGFullRelease As String = Nothing


                theSession.LogFile.WriteLine("Executing ... " & _
                    System.Reflection.Assembly.GetExecutingAssembly().Location)

                Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
                Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")

                UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")
                UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")

                System.Windows.Forms.Application.EnableVisualStyles()

                Dim MyUndoMark As Session.UndoMarkId = _
                    theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects")

                ' uncomment the following lines to check for the correct application
                Dim AppID As Integer = UFConstants.UF_APP_NONE
                theUFSession.UF.AskApplicationModule(AppID)
                If AppID <> UFConstants.UF_APP_CAM Then
                    theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
                    Exit Function
                End If

                For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1
                    Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)

                    If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then
                        Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)

                        Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")

                        Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)

                        Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)

                        theNcGroup.SetName(theGroupName)

                        Dim theCounter As Integer = 0

                        For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()
                            If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then
                                theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)

                                theCounter += 1

                                If theCounter > 99 Then Exit For
                            End If
                        Next
                    End If
                Next

I removed the "Sub" to fit the journal in to the _cb .... is there the fail?

If i klick the button nothing happens.

 

I'm really stucked in this siuation Smiley Frustrated 

If someone could give me a hint or an example would be very helpful. I also had a look in the solution center but found not very much in this case.

 

I'm really not a developer. But i'm intrested in the functionality of nx open.Smiley Happy

 

Thank you all for your assistence

 

Best regards 


Production: {NX 10.0.3.5 MP18}
Testing: {NX 12.0.2.9 MP03}
2 REPLIES 2

Re: Rename Operations in Blockstyler

Phenom
Phenom

I use the 'update_cb' to update the data in the Blockstyler ie the GUI

In the 'apply_cb', once you have done the data chek (if any) then call you re-naming function. Something like that

 

Public Function apply_cb() As Integer
' check all the user input. for each error found increment variable errorCode +1

If errorCode = 0 Then MyRenamingFunction(param1,param2) Else 'errorCode <> 0 LeaveMacroMsg() Return -1 End if apply_cb = errorCode
End sub
Production: NX.CAE 10.0.2.6
Development: VB.NET (amateur level !)

Re: Rename Operations in Blockstyler

Valued Contributor
Valued Contributor

Thank you for your answer

 

Thank you for your explanation in wich _cb i should  set my code. This works fine. But i have a code issue  in this code i posted

Well i am a beginner in VB.net. But i think there is something by selecting the programm group.

 

Has someone an example in blockstyler wich a operation or a programmgroup gets selected? 

 

Thank you all for your assistence :-)


Production: {NX 10.0.3.5 MP18}
Testing: {NX 12.0.2.9 MP03}