Bcc.OutputAPTFile(FileName)

Bcc.OutputAPTFile(FileName, ObjectID, Options)

Bcc.OutputAPTFile(FileName, ObjectName, Options)

Description

This function will create the APT program of the active job in the CAM tree and write it to disk.  


Optionally you may also pass an object name or object ID in the event the document has multiple jobs and you wish to post out the program for the second or higher job, in which case you must provide an ID or name that exists in the appropriate job. 

IMPORTANT:  This function will always post the entire job, respecting the Post Yes/No flag of all items.

Parameters

The primary input of this function is a Table which can include the following keys:


  • FileName – the path and file name of that should be created containing the posted NC program

  • ObjectName – the name of the a CAM item in the tree associated to a Job which you want posted.


       Note: Please visit Bcc.GetSelectedCamObjName for more information on retrieving the selected objects name


  • ObjectID - the integer ID of the a CAM item in the tree associated to a Job which you want posted.  


Note: Please visit Bcc.GetSelectedCamObjID for more information on retrieving the selected objects ID


  • Options – a Table which contains optional parameters for controlling the APT output

    • Keys for this table are the following:
      • IsSupportCannedCycle - boolean value of whether to output drilling cycles using the canned cycle format or long hand code
      • IsOutputCutterFirst - boolean value which determines the order in which to output the LOADTL or CUTTER command first in the APT output
      • IsBreakArc - boolean value to determine if all arcs should be converted to line segments using the ArcBreakTol value.
      • IsBreak3DArc - boolean value to determine all 3D arcs should be converted to line segments using the ArcBreakTol value. 
        • The definition of a "3D Arc" is any arc that does NOT lie directly on the G17 / G18 / G19 plane with the tool orientation pointing perpendicular to the three main planes.
        • NOTE:  At this time the tool vector will come from the end point of the arc and will be consistent along the entire arc.
      • ArcBreakTol - double value representing the chordal tolerance used for breaking the arc into line segments.  
        • If this value is excluded a default of 0.0005 inches (0.0127 mm) will be used in the case of breaking arcs.

Examples


-- Post the APT program for the first job in the CAM tree

Bcc.OutputAPTFile("C:\\PostedProgram.apt")


-- Post the APT program for the job named "Milling Job 2"

Bcc.OutputAPTFile("C:\\PostedProgram.apt", "Milling Job 2", {IsSupportCannedCycle=false, IsOutputCutterFirst=true })


-- Post the APT program for the selected CAM job in the tree

Bcc.OutputAPTFile("C:\\PostedProgram.apt", Bcc.GetSelectedCamObjID(), {IsSupportCannedCycle = true, IsOutputCutterFirst = false })


-- Output the whole job without using the user selected item in the CAM tree but setting the Options

Bcc.OutputAPTFile("C:\\PostedProgram.apt", nil, {IsSupportCannedCycle=true, IsOutputCutterFirst=true})


-- Output the whole job with breaking all arcs into line segments using a 0.015mm arc break tolerance

Bcc.OutputAPTFile("C:\\PostedProgram.apt", nil, {IsSupportCannedCycle=true, IsOutputCutterFirst = false, IsBreakArc=true, ArcBreakTol=0.015})


-- Output the whole job with breaking only the 3D arcs into line segments using a 0.015mm arc break tolerance

Bcc.OutputAPTFile("C:\\PostedProgram.apt", nil, {IsSupportCannedCycle=true, IsOutputCutterFirst = false, IsBreak3DArc=true, ArcBreakTol=0.015})


Complete Example

---------------------------------------------------------------

-- Output APT file for the existing job in the tree          --

-- Ask for where to save and provide the options             --

---------------------------------------------------------------

-- Currently only implemented for Milling jobs               --

---------------------------------------------------------------

function OutputAPT()

       -- Present file save dialog for user to choose file name and where to save

       file = Bcc.FileSaveDialogBox( { Filter = "APT File (*.apt)|*.apt|All Files (*.*)|*.*", FilterIndex = 1 })

                                               

       if file ~= nil then

               -- Create the options UI to present

               dataCannedCycle = { ControlID = "IsSupportCannedCycle", ControlType = "CheckBox", Text = "Support Canned Cycle?", IsChecked = false }

               dataToolFirst = { ControlID = "IsOutputCutterFirst", ControlType = "CheckBox", Text = "Output CUTTER before LOADTL?", IsChecked = true }

               dataBreakArc = { ControlID = "IsBreakArc", ControlType = "CheckBox", Text = "Break all arcs to lines?", IsChecked = false }

               dataBreak3DArc = { ControlID = "IsBreak3DArc", ControlType = "CheckBox", Text = "Break only 3D arcs?", IsChecked = true }

               dataArcBreakTol = { ControlID = "ArcBreakTol", ControlType = "TextBox", Label = "Arc Break Tolerance", Value = 0.0127, ValueType = "DoubleUnit" }

               

               dataOptionsGroup = { ControlID = "optGroup", ControlType = "GroupBox", Header = "Options", 

                                 ListControls = {dataCannedCycle, dataToolFirst, dataBreakArc, dataBreak3DArc, dataArcBreakTol} }

               windowParams = { Title = "APT Format Options", Width = 300 }

               

               -- Display the dialog and get the user choices

               retTable = Bcc.ShowDialogBox(windowParams, {dataOptionsGroup})

               

               

               if retTable ~= nil        then

                       -- Create the APT file for the job in the CAM tree using the selected user options

                       Bcc.OutputAPTFile(file, nil, {IsSupportCannedCycle = retTable["IsSupportCannedCycle"]["IsChecked"], 

                                                     IsOutputCutterFirst = retTable["IsOutputCutterFirst"]["IsChecked"], 

                                                             IsBreakArc = retTable["IsBreakArc"]["IsChecked"], 

                                                               IsBreak3DArc = retTable["IsBreak3DArc"]["IsChecked"],

                                                               ArcBreakTol = retTable["ArcBreakTol"]["Value"]})                

               end

       end

end --end of the OutputAPT