×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create new program object - journal

Create new program object - journal

Create new program object - journal

(OP)
Here is a journal which creates cam program object. New program name is created from previously selected program name number +1 ( name[Integer] +1). Is it possible for journal to automatically find last created program (without preselect) get its name and create new one.
PS. How to check if Cam Object is program object and how to check if program already exists.

CODE

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

Module nextprog

    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 selectedTags() As NXOpen.Tag
        Dim selectedCount As Integer

        ' If there is a work part only then we can go further
        If WorkPart IsNot Nothing Then

            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)

                If selectedCount = 0 Then
                    MsgBox("Nothing selected", MsgBoxStyle.Exclamation)
                    Exit Sub
                End If
				
                Dim i As Integer

                For i = 0 To selectedCount - 1
				  Dim camObject As NXObject = NXObjectManager.Get(selectedTags(i))


          Dim CurrentName As String = camObject.Name()
				
				
				Dim value As String = CurrentName

				Dim int As Integer
				int = CInt(value)
				Dim Newname As Integer 
				Newname = int+1
		   
					 Dim nCGroup1 As CAM.NCGroup = CType(workPart.CAMSetup.CAMGroupCollection.FindObject("NC_PROGRAM"), CAM.NCGroup)
 

        Dim nCGroup2 As CAM.NCGroup
        nCGroup2 = workPart.CAMSetup.CAMGroupCollection.CreateProgram(nCGroup1, "mill_contour", "PROGRAM", CAM.NCGroupCollection.UseDefaultName.False, Newname)

       Dim programOrderGroupBuilder1 As CAM.ProgramOrderGroupBuilder
        programOrderGroupBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateProgramOrderGroupBuilder(nCGroup2)
		
        Dim nXObject1 As NXObject
        nXObject1 = programOrderGroupBuilder1.Commit()
        programOrderGroupBuilder1.Destroy()
					   
					   
                Next i
  
            End If

        End If
    End Sub

End Module 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources