forum.featurecam.com
http://forum.featurecam.com/

SetupSheet.bas Chamfermill LOC addition
http://forum.featurecam.com/viewtopic.php?f=11&t=1259
Page 1 of 1

Author:  vf1kf [ Mon Dec 12, 2011 11:56 pm ]
Post subject:  SetupSheet.bas Chamfermill LOC addition

Hi guys. I have been using a modified toollist section of setupsheet.bas supplied with featurecam to make tool lists for my operators. I was tired of seeing a blank space in the chamfermill section under Length. So I added some code ( more for my own API education than anything else, I have zero OOP experience ). I thought I'd share my changes in case someone else might benefit. Below is posted my modified private function for gimmeLength.

Code:
' each tool type has a different way of referring to the length.
' this function handles that situation.
Private Function gimmeLength( tool As FMTool ) As String

   On Error Resume Next
   Dim strLen As String
   Dim diameter As Double
   Dim toolangle As Double
   Dim angleasradians As Double
   Dim result As Double
   Dim pi As Double

   pi = 3.14159265358979323846264338327950288419716939937510
   diameter = tool.OuterDiameter
   toolangle = tool.angle

      If tool.ToolGroup = eTG_EndMill Or _
         tool.ToolGroup = eTG_PlungeRough Or _
         tool.ToolGroup = eTG_ThreadMill Then
         strLen = Format( tool.CutterLength, "0.000" )
      ElseIf tool.ToolGroup = eTG_TwistDrill Or _
         tool.ToolGroup = eTG_Tap Or _
         tool.ToolGroup = eTG_SpotDrill Or _
         tool.ToolGroup = eTG_CounterBore Then
         strLen = Format( tool.Length, "0.000" )
      ElseIf tool.ToolGroup = eTG_FaceMill Then
         strLen = Format( tool.Height, "0.000" )
      ElseIf tool.ToolGroup = eTG_ChamferMill Then
         angleasradians = (90-toolangle)/180*pi  ' Convert the tool angle in degrees to radians
         result = Tan(angleasradians)*diameter   ' Multiply resulting ratio by the tool diameter
         strLen = Format( result, "0.000" )
      Else
         ' we're not done yet... more code left to write here...BackBore...BoringBar...CounterSink...LatheTool...Ream...RoundingMill...SideMill...ThreadTool
         strLen = "—"
      End If
      gimmeLength = strLen

End Function


My changes were adding at the top:
Code:
     
   On Error Resume Next
   ...
   Dim diameter As Double
   Dim toolangle As Double
   Dim angleasradians As Double
   Dim result As Double
   Dim pi As Double

   pi = 3.14159265358979323846264338327950288419716939937510
   diameter = tool.OuterDiameter
   toolangle = tool.angle


And adding the eTG_ChamferMill section:
Code:
ElseIf tool.ToolGroup = eTG_ChamferMill Then
         angleasradians = (90-toolangle)/180*pi  ' Convert the tool angle in degrees to radians
         result = Tan(angleasradians)*diameter   ' Multiply resulting ratio by the tool diameter
         strLen = Format( result, "0.000" )

Author:  neville [ Thu Jan 10, 2013 9:22 am ]
Post subject:  Re: SetupSheet.bas Chamfermill LOC addition

That's great stuff. i had been fiddling with the similar code for quite some but was getting one or two thing wrong. Now it will help in my code execution.

___________________________
wire straightening and cutting

Author:  vf1kf [ Tue Jan 15, 2013 6:39 pm ]
Post subject:  Re: SetupSheet.bas Chamfermill LOC addition

Great, I'm glad it was of use to you :D

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/