Showing results for 
Search instead for 
Do you mean 
Reply

Sample vb program to create mill holder from curves or solid

[ Edited ]

In 2015, a Siemens PLM Hackathon team created a prototype using the API to create a Mill/Drill tool holder. The program uses the geometry of a profile or revolved solid to define a holder on the selected tool. The program has several limitations, but we feel there is value in what is there, so we are distributing it as a sample program.

HolderDefinition_background_current_process.jpg

HolderDefinition_background_what_does_program_do.jpg

 

(view in My Videos)

If this interests you, download the attachment, which contains the program and a README file that explains how to install and run the program.

  

If you make improvements, or have other suggestions on how to use it, please let me know.

March 28, 2017 - updated with drill tool builders.

 

Mark Rief
Retired Siemens
11 REPLIES

Re: Sample vb program to create mill holder from curves or solid

Simply badass Mark!

Badass!

NX11.0.1

Re: Sample vb program to create mill holder from curves or solid

Hmm... Sounds like something I suggested a long time ago :-)

(I'm sure others have as well.)

 

THANK YOU!

 

Ken

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Sample vb program to create mill holder from curves or solid

Hi Mark

 

What are the chances we can get something like this for User Defined Tools?

 

NX11.0.1

Re: Sample vb program to create mill holder from curves or solid

UDT

 

Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports System.Windows.Forms
Imports NXOpen.CAM
Imports NXOpen.Utilities

Module NXJournal
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim displayPart As Part = theSession.Parts.Display

        Dim file As String
        Dim OpenFileDialog1 As New OpenFileDialog()

        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            file = OpenFileDialog1.FileName
        Else
            Exit Sub
        End If

        Dim type As String
        Dim length_txt As String
        Dim angle_txt As String
        Dim length As Double
        Dim angle As Double
        Dim radius As String
        Dim sweep As Double
        Dim sr As New System.IO.StreamReader(file)

        theSession.CleanUpFacetedFacesAndEdges()

        Dim nCGroup1 As NXOpen.CAM.NCGroup = CType(workPart.CAMSetup.CAMGroupCollection.FindObject("GENERIC_MACHINE"), NXOpen.CAM.NCGroup)

        Dim nCGroup2 As NXOpen.CAM.NCGroup = Nothing
        nCGroup2 = workPart.CAMSetup.CAMGroupCollection.CreateTool(nCGroup1, "mill_planar", "MILL_USER_DEFINED", NXOpen.CAM.NCGroupCollection.UseDefaultName.True, "TEST_NAME")

        Dim tool1 As CAM.Tool = CType(nCGroup2, CAM.Tool)
        Dim millFormToolBuilder1 As CAM.MillFormToolBuilder
        millFormToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillFormToolBuilder(tool1)
        millFormToolBuilder1.Segments.Delete(2)
        millFormToolBuilder1.Segments.Delete(1)
        millFormToolBuilder1.Segments.Delete(0)

        Dim i As Integer = 1
        Dim line As String
        While sr.EndOfStream = False
            line = sr.ReadLine()
            If line = "Information on object # " & i Then
                i = i + 1
            Else
            End If
        End While

        sr.BaseStream.Seek(0, SeekOrigin.Begin)
        sr.DiscardBufferedData()

        Dim ii As Int32 = 0
        Dim newitemindex1 As Integer
        Do
            Do
                line = sr.ReadLine()
            Loop Until line = "Information on object # " & (ii + 1)
            type = sr.ReadLine()

            If type = "Line" Then
                angle_txt = sr.ReadLine()
                angle_txt = Replace(angle_txt, "Angle = ", "")
                angle_txt = Replace(angle_txt, "Angle = ", "")
                angle_txt = Replace(angle_txt, "Angle = ", "")
                length_txt = sr.ReadLine()
                length_txt = Replace(length_txt, "Length = ", "")
                length_txt = Replace(length_txt, "Length = ", "")
                length_txt = Replace(length_txt, "Length = ", "")

                If Double.TryParse(angle_txt, angle) Then
                Else
                End If

                If Double.TryParse(length_txt, length) Then
                Else
                End If

                newitemindex1 = millFormToolBuilder1.Segments.CreateWithParameter(length, angle, 0, 0)
                millFormToolBuilder1.Segments.ModifyWithParameter(ii, length, angle, 0, 0)

            ElseIf type = "Arc" Then

                sr.ReadLine()
                radius = sr.ReadLine()
                sr.ReadLine()
                sweep = sr.ReadLine()

                If angle = "" Then
                    angle = 0.0
                Else
                End If

                newitemindex1 = millFormToolBuilder1.Segments.CreateWithParameter(0, angle, radius, sweep)
                millFormToolBuilder1.Segments.ModifyWithParameter(ii, 0, angle, radius, sweep)

            End If

            ii = ii + 1
        Loop Until ii = (i - 1)
sr.Close()
End Sub End Module

 

 

 

Re: Sample vb program to create mill holder from curves or solid


CWilson wrote:

UDT

 


@CWilson, This looks interesting. what is the input file?

Mark Rief
Retired Siemens

Re: Sample vb program to create mill holder from curves or solid

I am currently updating some legacy tools that we just havent updated for years and this is a very handy tool. Works great for "milling tool-5 Parameters" (Tool Description) but are there tweeks that could be made to get one to work with a "Drilling Tool" as well?

 

Thanks

Re: Sample vb program to create mill holder from curves or solid


Mbruggeman wrote:

I am currently updating some legacy tools that we just havent updated for years and this is a very handy tool. Works great for "milling tool-5 Parameters" (Tool Description) but are there tweeks that could be made to get one to work with a "Drilling Tool" as well?

 

Thanks


The holder program works on milling and drilling tools.

Mark Rief
Retired Siemens

Re: Sample vb program to create mill holder from curves or solid

Here is a little movie of the issue im having. The first tool is a 'Milling Tool-5 Parameters' and the journal runs flawlessly. The second tool I create is a 'drilling tool' and the journal looks like it runs but does not define a holder. Do you need to select the solid/profile different for a drilling tool or am I missing something and running it wrong? I was looking through all the examples provided but didnt see an actual drilling tool. So I wasn't positive that it was possitive..

 

thanks

 

Re: Sample vb program to create mill holder from curves or solid

@Mbruggeman you're right - in only works on milling tools. I'll look at updating the program. 

It should not be a big deal - the intent is that you export the holder to the library, and in the library mill/drill holders are the same.

Mark Rief
Retired Siemens

Learn online





Solution Information