Guest User

post

a guest
Oct 6th, 2025
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 105.46 KB | None | 0 0
  1. [POST_VERSION] #DO NOT MOVE OR ALTER THIS LINE# V20.00 P0 E1 W20.00 T1661810539 M20.00 I0 O0
  2. # Post Name : MPMASTER
  3. # Product : MILL
  4. # Machine Name : MACHINE
  5. # Control Name : CONTROL
  6. # Description : IHS MASTER GENERIC MILL G-CODE POST
  7. # 4-axis/Axis subs. : YES
  8. # 5-axis : NO
  9. # Subprograms : YES
  10. # Executable : MP v9.19
  11. # Post Revision : 9.1.04114 (MC_FULL.MC_MINOR.YYDDD)
  12. #
  13. # WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO
  14. # THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE.
  15. #
  16. # --------------------------------------------------------------------------
  17. # Revision log:
  18. # --------------------------------------------------------------------------
  19. # Programmers Note:
  20. # IHS 01/30/02 - Mpmaster based on CNC Software's V8/V9 Mpfan, dat
  21. # IHS 01/30/02 - Initial post update for V9, dat
  22. # IHS 04/01/02 - Comments repeated in translational subs, dat
  23. # IHS 05/01/02 - lock_codes logic tweak, dat
  24. # IHS 05/07/02 - arccheck set to 3, dat
  25. # IHS 05/17/02 - Removed null comment from subs, dat
  26. # IHS 05/24/02 - Rotary subprograms mod, dat
  27. # IHS 07/17/02 - Incremental drilling calculation mod, dat
  28. # IHS 07/25/02 - Switch added to control rotary index move retracts, dat
  29. # IHS 10/07/02 - force_dpts switch added, dat
  30. # IHS 10/28/02 - Additional rotary sub logic mod, dat
  31. # IHS 11/06/02 - Switch added for 4/3 decimal place tapping feeds, dat
  32. # IHS 03/10/03 - Synched with updates to Mpfan from V9.1, dat
  33. # IHS 04/30/03 - arccheck set to 1, dat
  34. # IHS 05/08/03 - A2100-style G18/G19 helical move corrections, dat
  35. # IHS 06/27/03 - Initial post update for V9.1 SP1, dat
  36. # IHS 10/23/03 - Roughed out auto-launch of HTML.set, dat
  37. # IHS 12/12/03 - Comp on arc move warning added, dat
  38. # IHS 04/23/04 - non-retract index mod, dat
  39. # XXX MM/DD/04 - Written for Company X from Mpmaster, xxx
  40. #
  41. # --------------------------------------------------------------------------
  42. # Features:
  43. # --------------------------------------------------------------------------
  44. # This post supports Generic Fanuc code output for 3 and 4 axis milling.
  45. # It is designed to support the features of Mastercam Mill V9.
  46. #
  47. # Following Misc. Integers are used:
  48. # mi2 - Absolute or Incremental positioning at top level
  49. # 0 = absolute
  50. # 1 = incremental
  51. #
  52. # mi9 - Lock on First WCS - Set in first operation
  53. # 0 = No
  54. # 1 = Yes
  55. #
  56. # mi10 - M00 before operation
  57. # 0 = No
  58. # 1 = Yes
  59. #
  60. # Work offsets:
  61. # wcstype - Work coordinate system
  62. # 0 = Reference return is generated and G92 with the
  63. # X, Y and Z home positions at file head.
  64. # 1 = Reference return is generated and G92 with the
  65. # X, Y and Z home positions at each tool.
  66. # 2 = WCS of G54, G55.... based on Mastercam settings.
  67. # 0 thru 5 = The WCS of G54 thru G59 respectively.
  68. # 6 and up = The WCS of G54.1 P1 and up.
  69. # 3 = Off
  70. #
  71. #Canned text:
  72. # Entering cantext on a contour point from within Mastercam allows the
  73. # following functions to enable/disable.
  74. # Cantext value:
  75. # 1 = Stop = output the "M00" stop code
  76. # 2 = Ostop = output the "M01" optional stop code
  77. # 3 = Bld on = turn on block delete codes in NC lines
  78. # 4 = bLd off = turn off block delete codes in NC lines
  79. # 5 = Dwell = Input G04 P1 command
  80. #
  81. #Milling toolpaths (4 axis)
  82. #Layout:
  83. # The term "Reference View" refers to the coordinate system associated
  84. # with the Top view (Alt-F9, the upper gnomon of the three displayed).
  85. # Create the part drawing with the axis of rotation about the axis
  86. # of the "Reference View" according to the setting you entered for
  87. # 'vmc' (vertical or horizontal) and 'rot_on_x' (machine relative
  88. # axis of rotation).
  89. # vmc = 1 (vertical machine) uses the top toolplane as the base machine
  90. # view.
  91. # vmc = 0 (horizontal machine) uses the front toolplane as the base machine
  92. # view.
  93. # Relative to the machine matrix -
  94. # Rotation zero position is on the Z axis for rotation on X axis.
  95. # Rotation zero position is on the Z axis for rotation on Y axis.
  96. # Rotation zero position is on the X axis for rotation on Z axis.
  97. # The machine view rotated about the selected axis as a "single axis
  98. # rotation" are the only legal views for 4 axis milling. Rotation
  99. # direction around the part is positive in the CCW direction when
  100. # viewed from the plus direction of the rotating axis. Set the variable
  101. # 'rot_ccw_pos' to indicate the signed direction. Always set the work
  102. # origin at the center of rotation.
  103. #
  104. #Toolplane Positioning:
  105. # Create the Cplane and Tplane as the rotation of the machine view about
  106. # the selected axis of rotation. The toolplane is used to calculate
  107. # the position of the rotary axis. This is the default setting.
  108. #
  109. #3 Axis Rotary (Polar)
  110. # Polar positioning is offered in Mastercam 3 axis toolpaths through the
  111. # rotary axis options dialog. The selected toolpath is converted to angle
  112. # and radius position. The axis of rotation is forced to zero.
  113. #
  114. #Axis substitution:
  115. # Use the Rotary axis substitution by drawing the geometry flattened
  116. # from the cylinder. The rotary axis button must be active for axis
  117. # substitution information to be output to the NCI file. The radius of
  118. # the rotary diameter is added to all the Z positions at output.
  119. #
  120. #Simultaneous 4 Axis (11 gcode):
  121. # Full 4 axis toolpaths can be generated from various toolpaths under the
  122. # 'multi-axis' selection (i.e. Rotary 4 axis). All 5 axis paths are
  123. # converted to 4 axis paths where only the angle about the rotation axis
  124. # is resolved.
  125. #
  126. #Drill:
  127. # All drill methods are supported in the post. See Simultaneous 4 Axis.
  128. #
  129. #Additional Notes:
  130. # 1) Disable 4 axis by setting the numbered question 164. to 'n'.
  131. # 2) G54 calls are generated where the work offset entry of 0 = G54,
  132. # 1 = G55, etc.
  133. # 3) Metric is applied from the NCI met_tool variable.
  134. # 4) Incremental mode calculates motion from home position at toolchanges.
  135. # The home position is used to define the last position of the tool
  136. # for all toolchanges.
  137. # 5) The variable 'absinc' is now pre-defined, set mi2 (Misc. Integer) for
  138. # the 'top level' absolute/incremental program output. Subprograms are
  139. # updated through the Mastercam dialog settings for sub-programs.
  140. # 6) Always avoid machining to the center of rotation with rotary axis!
  141. # 7) Transform subprograms are intended for use with G54.. workshifts.
  142. #
  143. # END_HEADER$
  144. #
  145. # --------------------------------------------------------------------------
  146. # General Output Settings
  147. # --------------------------------------------------------------------------
  148. spaces$ : 1 #Number of spaces to add between fields
  149. omitseq$ : yes$ #Omit sequence numbers?
  150. seqmax$ : 9999 #Max. sequence number
  151. arcoutput$ : 0 #0 = IJK, 1 = R no sign, 2 = R signed neg. over 180
  152. arctype$ : 2 #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.
  153. breakarcs$ : 0 #Break arcs, 0 = no, 1 = quadrants, 2 = 180deg. max arcs
  154. do_full_arc$ : 1 #Allow full circle output? 0=no, 1=yes
  155. helix_arc$ : 1 #Support helix arc output, 0=no, 1=all planes, 2=XY plane only
  156. compwarn : 1 #Warn if cutter comp applied on arc, 0=no, 1=yes
  157. maxrad$ : 999 #Maximum arc radius
  158. hel_2100 : no$ #Acramatic 2100 style helical moves, 0=no, 1=yes
  159. usecanned : yes$ #Use canned drilling cycles? Set to no for long output.
  160. force_dpts : no$ #Force XY output on all drilling lines including cycle call?
  161. wcstype : 2 #0 = G92 at start, 1 = G92 at toolchanges, 2 = G54, 3 = Off
  162. force_wcs : yes$ #Force WCS output at every toolchange?
  163. stagetool : 1 #0 = Do not pre-stage tools, 1 = Stage tools
  164. tool_table : 1 #Tool table, 0=no, 1=yes, 2=Predator VCNC, 3=MetaCut View
  165. output_z : yes$ #Output Z Min and Z Max values (yes or no)
  166. cool_zmove : yes$ #Coolant off with last move
  167. use_pitch : 0 #0 = Use feed for tapping, 1 = Use pitch for tapping
  168. tap_feed : 0 #0 = 2/1 (in/mm) decimal places, 1 = 4/3 (in/mm) decimal places
  169. maxfeedpm : 500 #Limit for feed in inch/min
  170. maxfeedpm_m : 2000 #Limit for feed in mm/min
  171. use_gear : 0 #Output gear selection code, 0=no, 1=yes
  172. max_speed : 10000 #Maximum spindle speed
  173. min_speed : 50 #Minimum spindle speed
  174. sextnc$ : ".NC" #NC extension override
  175.  
  176. # --------------------------------------------------------------------------
  177. # Rotary Axis Settings
  178. # --------------------------------------------------------------------------
  179. # Typical Vertical
  180. srotary : "A" #Rotary axis prefix
  181. vmc : 1 #0 = Horizontal Machine, 1 = Vertical Mill
  182. rot_on_x : 0 #Default Rotary Axis Orientation, See ques. 164.
  183. #0 = Off, 1 = About X, 2 = About Y, 3 = About Z
  184. # Typical Horizontal
  185. #srotary "B" #Rotary axis prefix
  186. #vmc : 0 #0 = Horizontal Machine, 1 = Vertical Mill
  187. #rot_on_x : 2 #Default Rotary Axis Orientation, See ques. 164.
  188. # #0 = Off, 1 = About X, 2 = About Y, 3 = About Z
  189. rot_ccw_pos : 1 #Axis signed dir, 0 = CW positive, 1 = CCW positive
  190. ret_on_indx : 1 #Machine home retract on rotary index moves, (0 = no, 1 = yes)
  191. index : 0 #Use index positioning, 0 = Full Rotary, 1 = Index only
  192. ctable : 5 #Degrees for each index step with indexing spindle
  193. one_rev : 0 #Limit rotary indexing between 0 and 360? (0 = No, 1 = Yes)
  194. lock_codes : 0 #Use rotary axis unlock/lock M-Codes? (0 = No, 1 = Yes)
  195. use_frinv : 0 #Use Inverse Time Feedrates in 4 Axis, (0 = no, 1 = yes)
  196. rot_feed : 1 #Use calculated rotary feed values, (0 = no, 1 = yes)
  197. maxfrdeg : 2000 #Limit for feed in deg/min
  198. maxfrinv : 999.99#Limit for feed inverse time
  199. frc_cinit : 1 #Force C axis reset at toolchange
  200. ctol : 225 #Tolerance in deg. before rev flag changes
  201. ixtol : 0.01 #Tolerance in deg. for index error
  202. frdegstp : 10 #Step limit for rotary feed in deg/min
  203.  
  204. # --------------------------------------------------------------------------
  205. # Debugging and Factory Set Program Switches
  206. # --------------------------------------------------------------------------
  207. fastmode$ : yes$ #Posting speed optimizition
  208. bug1$ : 2 #0=No display, 1=Generic list box, 2=Editor
  209. bug2$ : 60 #Append postline labels, non-zero is column position?
  210. bug3$ : 0 #Append whatline no. to each NC line?
  211. bug4$ : 0 #Append NCI line no. to each NC line?
  212. whatno$ : yes$ #Do not perform whatline branches? (leave as yes)
  213. linktolvar$ : 1 #Associate X tolerance variables to V9- variable?
  214. linkplnvar$ : 1 #Associate X plane specific variables to V9- variable?
  215.  
  216. # --------------------------------------------------------------------------
  217. # Additional General Output Settings
  218. # --------------------------------------------------------------------------
  219. nobrk$ : no$ #Omit breakup of x, y & z rapid moves
  220. progname$ : 1 #Use uppercase for program name (sprogname)
  221. sub_level$ : 1 #Enable automatic subprogram support
  222. sub_seq_typ$ : 1 #Enable subprogram sequence number reset at sub call
  223. arccheck$ : 1 #Check for small arcs, convert to linear
  224. atol$ : 0.01 #Angularity tolerance for arccheck
  225. ltol$ : 0.002 #Length tolerance for arccheck
  226. vtol$ : 0.001#System tolerance
  227. mtol$ : 0.000001#Avoid internal rounding assuming 6 dec NCI
  228. ltol_m : 0.05 #Length tolerance for arccheck, metric
  229. vtol_m : 0.025#System tolerance, metric
  230. tooltable$ : 1 #Read for tool table and pwrtt - use tool_table to disable
  231.  
  232. m_one : -1 #Define constant
  233. zero : 0 #Define constant
  234. one : 1 #Define constant
  235. two : 2 #Define constant
  236. three : 3 #Define constant
  237. four : 4 #Define constant
  238. five : 5 #Define constant
  239. c9k : 9999 #Define constant
  240.  
  241. skp_lead_flgs$ : 0 #Do NOT use v9 style contour flags
  242. get_1004$ : 1 #Find gcode 1004 with getnextop?
  243. rpd_typ_v7$ : 0 #Use Version 7 style contour flags/processing?
  244. strtool_v7$ : 1 #Use Version 7 toolname? [0=Filename,1=Name,2=Path\Name]
  245. tlchng_aft$ : 2 #Delay call to toolchange until move line
  246. cant_tlchng$ : 1 #Ignore cantext entry on move with tlchng_aft
  247. newglobal$ : 1 #Error checking for global variables
  248. getnextop$ : 1 #Build the next variable table
  249. error_msg$ : 1 #0=file and prompt, 1=to screen, 2=one to screen
  250. err_file$ : 1 #0=fatal, 1=all errors, 2=inc mprint, 3=inc prompts, 4=always
  251.  
  252. # --------------------------------------------------------------------------
  253. # Enable Canned Drill Cycle Switches
  254. # --------------------------------------------------------------------------
  255. usecandrill$ : yes$ #Use canned cycle for drill
  256. usecanpeck$ : yes$ #Use canned cycle for Peck
  257. usecanchip$ : yes$ #Use canned cycle for Chip Break
  258. usecantap$ : yes$ #Use canned cycle for Tap
  259. usecanbore1$ : yes$ #Use canned cycle for Bore1
  260. usecanbore2$ : yes$ #Use canned cycle for Bore2
  261. usecanmisc1$ : yes$ #Use canned cycle for Misc1
  262. usecanmisc2$ : yes$ #Use canned cycle for Misc2
  263.  
  264. # --------------------------------------------------------------------------
  265. # Common User-defined Variable Initializations (not switches!)
  266. # --------------------------------------------------------------------------
  267. xia : 0 #Formated absolute value for X incremental calculations
  268. yia : 0 #Formated absolute value for Y incremental calculations
  269. zia : 0 #Formated absolute value for Z incremental calculations
  270. cia : 0 #Formated absolute value for C incremental calculations
  271.  
  272. cuttype : 0 #Cut type flag
  273. #0 = Tool Plane, 1 = Axis Subs, 2 = Polar, 3 = 4/5 axis
  274. bld : 0 #Block delete active
  275. result : 0 #Return value for functions
  276. sav_spc : 0 #Save spaces
  277. sav_gcode : 0 #Gcode saved
  278. sav_absinc : 0 #Absolute/Incremental Saved Value
  279. sav_coolant : 0 #Coolant saved
  280. sav_workofs : 0 #Saved work offset
  281. sav_frc_wcs : 0 #Force work offset flag saved
  282. sav_progno : 0 #Saved program number
  283. #sav_n1 : 0 #Saved sequence number
  284. #sav_n2 : 0 #Saved sequence number
  285. sav_rot_on_x : 0 #Rotary configuration saved
  286. toolchng : 1 #On a toolchange flag
  287. spdir2 : 1 #Copy for safe spindle direction calculation
  288.  
  289. #Drill variables
  290. drlgsel : -1 #Drill Select Initialize
  291. drillref : 0 #Select drill reference
  292. peckacel$ : 0 #Fractional percent to reduce peck2 when usecan.. : no
  293. drlgcode : 0 #Save Gcode in drill
  294. sav_dgcode : 0 #Drill gcode saved
  295.  
  296. #Subprogram variables
  297. mr_rt_actv : 0 #Flag to indicate if G51/G68 is active
  298. #0=Off, 1=Toolchange, 2=Subprogram call/start, G68
  299. #3=Absolute start, both
  300. rt_csav : 0 #C saved value
  301. end_sub_mny : 0 #Many tool setting captured at transform sub end
  302.  
  303. #Rotary/Index variables
  304. csav : 0 #C saved value
  305. prvcabs : 0 #Saved cabs from pe_inc_calc,
  306. #Used for rotary feed and direction calculations
  307. cdelta : 0 #Calculation for angle change
  308. rev : 0 #Calculation for deg/min
  309. sav_rev : 0 #Saved revolution counter
  310. indx_out : c9k #Rotation direction calculation
  311. fmt 16 indx_mc #Rotation direction calculation
  312.  
  313. #Vector Constants for Rotatary Calculations
  314. aaxisx : 1 #A axis rotation vector constant
  315. aaxisy : 0 #A axis rotation vector constant
  316. aaxisz : 0 #A axis rotation vector constant
  317. baxisx : 0 #B axis rotation vector constant
  318. baxisy : 1 #B axis rotation vector constant
  319. baxisz : 0 #B axis rotation vector constant
  320. caxisx : 0 #C axis rotation vector constant
  321. caxisy : 0 #C axis rotation vector constant
  322. caxisz : 1 #C axis rotation vector constant
  323.  
  324. #Feedrate calculation variables
  325. frdelta : 0 #Calculation for deg/min
  326. frinv : 0 #Feedrate inverse time
  327. frdeg : 0 #Feedrate deg/min actual
  328. prvfrdeg : 0 #Feedrate deg/min actual
  329. ldelta : 0 #Calculation for deg/min, linear
  330. cldelta : 0 #Calculation for deg/min, linear and rotary
  331. circum : 0 #Calculation for deg/min
  332. ipr_type : 0 #Feedrate for Rotary, 0 = UPM, 1 = DPM, 2 = Inverse
  333.  
  334. #Misc variables
  335. tcnt : 1 # Count the number of tool changes
  336. toolcount : 1 # Tool counter for logic control
  337. toolcountn : 0 # Next tool counter for logic control
  338. toolcountp : 0 # Previous tool counter for logic control
  339. tooltotal : 0 # Tool tool count
  340. nexttool : 0 # Next actual tool
  341. nexttp : 1 # Next tool plane
  342. prvtp : 0 # Previous tool plane
  343. counter : 1 # Counter
  344. nstrlen : 0 # Length of string
  345. last_op_id : 0 # Previous internal operation id
  346. last_cuttype : 0 # Previous cuttype
  347. stock_typ : 0 # Predator Stock Type
  348. cyl_typ : 0 # Predator Cyl Stock Type
  349. z_min$ : 1000 # Min Z
  350. z_tmin : 1000 # Overall min Z
  351. z_max$ : -1000# Max Z
  352. z_tmax : -1000# Overall max Z
  353. tapflg : 0 # Flag for tap cycle
  354. sav_mi9 : 0 # Saved mi9 value
  355. rotretflg : 0
  356. compwarnflg : 0
  357.  
  358. # --------------------------------------------------------------------------
  359. # FORMULAS - global formulas
  360. # --------------------------------------------------------------------------
  361. toolcountn = toolcount + 1 # Index!
  362. toolcountp = toolcount - 1 # Index!
  363.  
  364. # --------------------------------------------------------------------------
  365. # Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
  366. # --------------------------------------------------------------------------
  367. #Default english/metric position format statements
  368. fs2 1 0.7 0.6 #Decimal, absolute, 7 place, default for initialize (:)
  369. fs2 2 0.4 0.3 #Decimal, absolute, 4/3 place
  370. fs2 3 0.4 0.3d #Decimal, delta, 4/3 place
  371. #Common format statements
  372. fs2 4 1 0 1 0 #Integer, not leading
  373. fs2 5 2 0 2 0l #Integer, force two leading
  374. fs2 6 3 0 3 0l #Integer, force three leading
  375. fs2 7 4 0 4 0l #Integer, force four leading
  376. fs2 8 5 0 5 0l #Integer, force five leading
  377. fs2 9 0.1 0.1 #Decimal, absolute, 1 place
  378. fs2 10 0.2 0.2 #Decimal, absolute, 2 place
  379. fs2 11 0.3 0.3 #Decimal, absolute, 3 place
  380. fs2 12 0.4 0.4 #Decimal, absolute, 4 place
  381. fs2 13 0.5 0.5 #Decimal, absolute, 5 place
  382. fs2 14 0.3 0.3d #Decimal, delta, 3 place
  383. fs2 15 0.2 0.1 #Decimal, absolute, 2/1 place (feedrate)
  384. fs2 16 1 0 1 0n #Integer, forced output
  385. fs 17 1.4lt #Decimal, absolute, four trailing
  386.  
  387. # --------------------------------------------------------------------------
  388. #String and string selector definitions for NC output
  389. # --------------------------------------------------------------------------
  390. #Numbered question 164. string to detect Rotary axis y/n
  391. sq164 : ""
  392.  
  393. #Address string definitions
  394. stri : "I"
  395. strj : "J"
  396. strk : "K"
  397. strm : "M"
  398. strn : "N"
  399. stro : "O"
  400. strp : "P"
  401. srad : "R"
  402. srminus : "R-"
  403. sblank : ""
  404.  
  405. #Cantext string definitions (spaces must be padded here)
  406. sm00 : "M00"
  407. sm01 : "M01"
  408. scant5 : "G04 P1"
  409. strtextno : ""
  410. strcantext : ""
  411.  
  412. #Transform mirror and rotate codes
  413. strns_mir_on : "G51.1" #Programmable mirror image code
  414. strns_mir_off : "G50.1" #Programmable mirror image cancel code
  415. strns_rot_on : "G68" #Coordinate System Rotation
  416. strns_rot_off : "G69" #Coordinate System Rotation Cancel
  417.  
  418. #Launch HTML.set during posting
  419. sdll : "C:\Mcam9\Chooks\MP_Multi.dll" # Name of the .DLL to be called
  420. spost1 : "HTML.SET"
  421. snci : ""
  422. sparams1 : ""
  423. sspace : " " # Contains a SPACE character
  424. ssq : "'" # Contains a Single Quote character
  425. sdq : '"' # Contains a Double Quote character
  426.  
  427. # --------------------------------------------------------------------------
  428. # Error messages
  429. # --------------------------------------------------------------------------
  430. saxiswarn : "WARNING-POST ROTARY AXIS ASSIGNMENT ('rot_on_x') OVERWRITTEN BY OPERATION"
  431. saxisoff : "ERROR-POST ROTARY AXIS ASSIGNMENT ('rot_on_x') IS DISABLED"
  432. saxiserror : "ERROR-INVALID ROTARY AXIS ASSIGNMENT ('rot_on_x') FOR CURRENT OPERATION"
  433. sindxerror : "WARNING-INDEX ANGLE DOES NOT MATCH POST SETTING ('ctable')"
  434. stlorgerr : "ERROR-TOOL ORIGIN DOES NOT MATCH CENTER OF ROTATION IN POLAR MILLING"
  435. shomeserror : "ERROR-G92 WORK OFFSET ('wcstype') DOES NOT SUPPORT TRANSFORM SUBPROGRAM"
  436. sprgnerror : "ERROR-SUBPROGRAM NUMBER MATCHES THE MAIN PROGRAM NUMBER"
  437. scompwarn : "WARNING-CUTTER COMP APPLIED ON ARC MOVE"
  438.  
  439. # --------------------------------------------------------------------------
  440. # Misc strings
  441. # --------------------------------------------------------------------------
  442. snull : "" # Null character string
  443. sdot : "." # dot string
  444. stest1 : "" # Test string 1
  445. stilde : "~" # Tidle string
  446. snocomm : "DEFINE TOOL NAMES"
  447. stoper : "" # String for tool notes
  448. spostname : "" # Post name
  449. snullop : "UNDEFINED OPERATION"
  450. slicense : "IN-HOUSE SOLUTIONS"
  451.  
  452. # ------------------------------------------------------------------------
  453. # Parameter Tables
  454. # ------------------------------------------------------------------------
  455. fprmtbl 13 2 # Multisurf Finish
  456. 10010 stock # Amount of stock to leave on drive surfs
  457. 10227 check # Amount of stock to leave on check surfs
  458.  
  459. fprmtbl 14 2 # Multisurf Rough
  460. 10010 stock # Amount of stock to leave on drive surfs
  461. 10227 check # Amount of stock to leave on check surfs
  462.  
  463. # --------------------------------------------------------------------------
  464. # Buffer 3 - Holds the variable 'tlplnno' for each toolpath segment
  465. # --------------------------------------------------------------------------
  466. rc3 : 1
  467. wc3 : 1
  468. fbuf 3 0 1 0 0 # Buffer 3
  469.  
  470. # --------------------------------------------------------------------------
  471. # Buffer 4 - Holds the variable 't' for each toolpath segment
  472. # --------------------------------------------------------------------------
  473. rc4 : 1
  474. wc4 : 1
  475. fbuf 4 0 1 0 0 # Buffer 4
  476.  
  477. # --------------------------------------------------------------------------
  478. # Buffer 5 - Min / Max
  479. # --------------------------------------------------------------------------
  480. b5_gcode : 0
  481. b5_zmin : 0
  482. b5_zmax : 0
  483. rc5 : 2
  484. wc5 : 1
  485. size5 : 0
  486.  
  487. fbuf 5 0 3 0 0 #Min / Max
  488.  
  489. # --------------------------------------------------------------------------
  490. # Question format statements
  491. # --------------------------------------------------------------------------
  492. fq 1 stock_typ "Predator Stock [0=Box,1=Cylindrical]"
  493. fq 2 cyl_typ "Cylindrical Stock Axis [1=X,2=Y,3=Z]"
  494.  
  495. # --------------------------------------------------------------------------
  496. # Strings - String labels must start with 's' - they are not pre-assigned
  497. # --------------------------------------------------------------------------
  498. #Select operation note
  499. sop00 : "NULL." # String definition
  500. sop01 : "CONTOUR." # " "
  501. sop02 : "CONTOUR." # " "
  502. sop03 : "DRILL/MISC." # " "
  503. sop04 : "POCKET." # " "
  504. sop05 : "RULED." # " "
  505. sop06 : "2D-SWEPT." # " "
  506. sop07 : "3D-SWEPT." # " "
  507. sop08 : "REVOLVED." # " "
  508. sop09 : "LOFT." # " "
  509. sop10 : "COONS." # " "
  510. sop11 : "FILLET." # " "
  511. sop12 : "FLOWLINE." # " "
  512. sop13 : "M.FINISH." # " "
  513. sop14 : "M.ROUGH." # " "
  514. sop15 : "POINT." # " "
  515. sop16 : "DRILL5AX." # " "
  516. sop17 : "CURVE5AX." # " "
  517. sop18 : "SWARF5AX." # " "
  518. sop19 : "FACING." # " "
  519. sop20 : "OP20." # " "
  520.  
  521. sopnote : "" # Target string
  522. fstrsel sop00 opcode$ sopnote 21 -1
  523.  
  524. # --------------------------------------------------------------------------
  525. #Select operation note
  526. sdr00 : "DRILL/CBORE" # String definition
  527. sdr01 : "PECK DRILL." # " "
  528. sdr02 : "CHIP BREAK." # " "
  529. sdr03 : "TAP." # " "
  530. sdr04 : "BORE 1." # " "
  531. sdr05 : "BORE 2." # " "
  532. sdr06 : "FINE BORE." # " "
  533. sdr07 : "MISC 2." # " "
  534. sdr08 : "CUST 9." # " "
  535. sdr09 : "CUST 10." # " "
  536. sdr10 : "CUST 11." # " "
  537. sdr11 : "CUST 12." # " "
  538. sdr12 : "CUST 13." # " "
  539. sdr13 : "CUST 14." # " "
  540. sdr14 : "CUST 15." # " "
  541. sdr15 : "CUST 16." # " "
  542. sdr16 : "CUST 17." # " "
  543. sdr17 : "CUST 18." # " "
  544. sdr18 : "CUST 19." # " "
  545. sdr19 : "CUST 20." # " "
  546.  
  547. sdrnote : "" # Target string
  548.  
  549. fstrsel sdr00 nextdc$ sdrnote 20 -1
  550.  
  551. # --------------------------------------------------------------------------
  552. # Select month
  553. smon00 : ""
  554. smon01 : "01"
  555. smon02 : "02"
  556. smon03 : "03"
  557. smon04 : "04"
  558. smon05 : "05"
  559. smon06 : "06"
  560. smon07 : "07"
  561. smon08 : "08"
  562. smon09 : "09"
  563. smon10 : "10"
  564. smon11 : "11"
  565. smon12 : "12"
  566. smonth : ""
  567.  
  568. fstrsel smon00 month$ smonth 13 -1
  569.  
  570. # --------------------------------------------------------------------------
  571. # General G and M Code String select tables
  572. # --------------------------------------------------------------------------
  573. # Motion G code selection
  574. sg00 : "G00" #Rapid
  575. sg01 : "G01" #Linear feed
  576. sg02 : "G02" #Circular interpolation CW
  577. sg03 : "G03" #Circular interpolation CCW
  578. sg04 : "G04" #Dwell
  579. sgcode : "" #Target for string
  580.  
  581. fstrsel sg00 gcode$ sgcode 5 -1
  582. # --------------------------------------------------------------------------
  583. # Select work plane G code
  584. sg17 : "G17" #XY plane code
  585. sg19 : "G19" #YZ plane code
  586. sg18 : "G18" #XZ plane code
  587. sgplane : "" #Target string
  588.  
  589. fstrsel sg17 plane$ sgplane 3 -1
  590. # --------------------------------------------------------------------------
  591. #Select english/metric code
  592. sg20 : "G20" #Inch code
  593. sg21 : "G21" #Metric code
  594. smetric : "" #Target string
  595.  
  596. fstrsel sg20 met_tool$ smetric 2 -1
  597. # --------------------------------------------------------------------------
  598. # Cutter compensation G code selection
  599. scc0 : "G40" #Cancel cutter compensation
  600. scc1 : "G41" #Cutter compensation left
  601. scc2 : "G42" #Cutter compensation right
  602. sccomp : "" #Target for string
  603.  
  604. fstrsel scc0 cc_pos$ sccomp 3 -1
  605. # --------------------------------------------------------------------------
  606. # Canned drill cycle string select
  607. sg81 : "G81" #drill - no dwell
  608. sg81d : "G82" #drill - with dwell
  609. sg83 : "G83" #peck drill - no dwell
  610. sg83d : "G83" #peck drill - with dwell
  611. sg73 : "G73" #chip break - no dwell
  612. sg73d : "G73" #chip break - with dwell
  613. sg84 : "G84" #tap - right hand
  614. sg84d : "G74" #tap - left hand
  615. sg76 : "G76" #bore #1 - no dwell
  616. sg76d : "G76" #bore #1 - with dwell
  617. sg86 : "G85" #bore #2 - no dwell
  618. sg86d : "G85" #bore #2 - with dwell
  619. sgm1 : "G76" #misc #1 - no dwell
  620. sgm1d : "G76" #misc #1 - with dwell
  621. sgm2 : "G84" #rigid tap - right hand
  622. sgm2d : "G82" #misc #2 - with dwell
  623. sgc9 : "G81" #custom #9 - no dwell
  624. sgc9d : "G82" #custom #9 - with dwell
  625. sgdrill : "" #Target for string
  626.  
  627. fstrsel sg81 drlgsel sgdrill 18 -1
  628. # --------------------------------------------------------------------------
  629. # Select incremental or absolute G code
  630. sg90 : "G90" #Absolute code
  631. sg91 : "G91" #Incremental code
  632. sgabsinc : "" #Target string
  633.  
  634. fstrsel sg90 absinc$ sgabsinc 2 -1
  635. # --------------------------------------------------------------------------
  636. # Feed mode G code selection
  637. sg94 : "G94" #UPM
  638. sg94d : "G94" #DPM, See pfcalc_deg if you use another gcode
  639. sg93 : "G93" #Inverse
  640. sgfeed : "" #Target for string
  641.  
  642. fstrsel sg94 ipr_type sgfeed 3 -1
  643. # --------------------------------------------------------------------------
  644. #Canned drill cycle reference height
  645. sg98 : "G98" #Reference at initht
  646. sg99 : "G99" #Reference at refht
  647. sgdrlref : "" #Target for string
  648.  
  649. fstrsel sg98 drillref sgdrlref 2 -1 # Drill cycle G string select
  650. # --------------------------------------------------------------------------
  651. # Generate string for spindle
  652. sm04 : "M4" #Spindle reverse
  653. sm05 : "M5" #Spindle off
  654. sm03 : "M3" #Spindle forward
  655. spindle : "" #Target for string
  656.  
  657. fstrsel sm04 spdir2 spindle 3 -1
  658. # --------------------------------------------------------------------------
  659. # Coolant M code selection
  660. sm09 : "M9" #Coolant Off (Use sm09_0 through sm09_2)
  661. sm08 : "M8" #Coolant Flood
  662. sm08_1 : "M40" #Coolant Mist
  663. sm08_2 : 'M8";"M40' #Coolant Tool
  664. sm09_0 : "M9" #Coolant Flood Off
  665. sm09_1 : "M41" #Coolant Mist Off
  666. sm09_2 : 'M9";"M41' #Coolant Tool Off
  667. scoolant : "" #Target for string
  668.  
  669. fstrsel sm09 coolant$ scoolant 7 -1
  670. # --------------------------------------------------------------------------
  671. # Table unlock and lock codes
  672. slock : "M10" #Axis lock
  673. sunlock : "M11" #Axis unlock
  674. # --------------------------------------------------------------------------
  675. # Table rotation direction
  676. # Table rotation direction, index
  677. sindx_cw : "M22" #Rotate CW code
  678. sindx_ccw : "M21" #Rotate CCW code
  679. sindx_mc : "" #Target for string
  680.  
  681. fstrsel sindx_cw indx_mc sindx_mc 2 -1
  682. # --------------------------------------------------------------------------
  683. # Define the gear selection code
  684. flktbl 1 3 #Lookup table definition - table no. - no. entries
  685. 40 0 #Low gear range
  686. 41 400 #Med gear range
  687. 42 2250 #Hi gear range
  688.  
  689. # --------------------------------------------------------------------------
  690. # Toolchange / NC output Variable Formats
  691. # --------------------------------------------------------------------------
  692. fmt T 4 t$ #Tool No
  693. fmt T 4 first_tool$ #First Tool Used
  694. fmt T 4 next_tool$ #Next Tool Used
  695. fmt D 4 tloffno$ #Diameter Offset No
  696. fmt H 4 tlngno$ #Length Offset No
  697. fmt G 4 g_wcs #WCS G address
  698. fmt P 4 p_wcs #WCS P address
  699. fmt S 4 speed #Spindle Speed
  700. fmt M 4 gear #Gear range
  701. # --------------------------------------------------------------------------
  702. fmt N 4 n$ #Sequence number
  703. fmt X 2 xabs #X position output
  704. fmt Y 2 yabs #Y position output
  705. fmt Z 2 zabs #Z position output
  706. fmt X 3 xinc #X position output
  707. fmt Y 3 yinc #Y position output
  708. fmt Z 3 zinc #Z position output
  709. fmt A 11 cabs #C axis position
  710. fmt A 14 cinc #C axis position
  711. fmt A 4 indx_out #Index position
  712. fmt R 14 rt_cinc #C axis position, G68
  713. fmt I 3 i$ #Arc center description in X
  714. fmt J 3 j$ #Arc center description in Y
  715. fmt K 3 k$ #Arc center description in Z
  716. fmt K 2 lead #Helical lead
  717. fmt R 2 arcrad$ #Arc Radius
  718. fmt F 4 feed #Feedrate
  719. fmt P 4 dwell$ #Dwell
  720. fmt M 5 cantext$ #Canned text
  721. # --------------------------------------------------------------------------
  722. #Move comment (pound) to output colon with program numbers
  723. fmt O 7 progno$ #Program number
  724. #fmt ":" 7 progno$ #Program number
  725. fmt O 7 main_prg_no$ #Program number
  726. #fmt ":" 7 main_prg_no$ #Program number
  727. fmt O 7 sub_prg_no$ #Program number
  728. #fmt ":" 7 sub_prg_no$ #Program number
  729. fmt P 7 sub_prg_call#Program number
  730. fmt X 2 sub_trnsx$ #Rotation point
  731. fmt Y 2 sub_trnsy$ #Rotation point
  732. fmt Z 2 sub_trnsz$ #Rotation point
  733. # --------------------------------------------------------------------------
  734. fmt Q 2 peck1$ #First peck increment (positive)
  735. fmt 2 peck2$ #Second or last peck (positive)
  736. fmt 2 peckclr$ #Safety distance
  737. fmt 2 retr$ #Retract height
  738. fmt Q 2 shftdrl$ #Fine bore tool shift
  739. fmt Z 2 zdrl$ #Depth of drill point
  740. fmt Z 2 tosz$ #Drilling top of stock
  741. fmt N 4 n_tap_thds$ #Number of threads per inch (tpi) / Pitch (mm)
  742. fmt F 2 pitch #Tap pitch (inches per thread)
  743. fmt R 2 refht_a #Reference height
  744. fmt R 2 refht_i #Reference height
  745. # --------------------------------------------------------------------------
  746. fmt "TOOL-" 4 tnote # Note format
  747. fmt "DIA.OFF. - " 4 toffnote # Note format
  748. fmt "LEN.-" 4 tlngnote # Note format
  749. fmt "DIA.-" 1 tldianote # Note format
  750. # --------------------------------------------------------------------------
  751. fmt D 2 tldia$ # Note format
  752. fmt R 2 tcr$ # Note format
  753. fmt D 2 tldia_pred # Predator VCNC format
  754. fmt C 2 tcr_pred # Predator VCNC format
  755.  
  756. fmt D 2 tldia_meta # MetaCut View format
  757. fmt R 2 tcr_meta # MetaCut View format
  758. fmt F 2 flute_meta # MetaCut View format
  759. fmt L 2 oa_meta # MetaCut View format
  760. fmt A 2 ta_meta # MetaCut View format
  761. fmt TD 2 td_meta # MetaCut View format
  762. fmt CD 2 cd_meta # MetaCut View format
  763. fmt CL 2 cl_meta # MetaCut View format
  764. fmt SD 2 sd_meta # MetaCut View format
  765. fmt C 4 tipcomp # MetaCut View format
  766.  
  767. fmt 2 slot # 20004 Parameter line
  768. fmt 2 tool_type
  769. fmt 2 matl_type
  770. fmt 2 corner_rad_type
  771. fmt 2 diameter
  772. fmt 2 corner_rad
  773. fmt 2 threads
  774. fmt A 2 tip_angle
  775. fmt 2 dia_off
  776. fmt 2 len_off
  777. fmt 2 tool_feed
  778. fmt 2 plunge
  779. fmt 2 retract
  780. fmt 2 rpm
  781. fmt 2 coolant1
  782. fmt 2 n_flutes1
  783. fmt A 2 tip_angle_ch
  784.  
  785. fmt 2 cut_ability # 20006 Parameter line
  786. fmt 2 step_r_xy
  787. fmt 2 step_r_z
  788. fmt 2 step_f_xy
  789. fmt 2 step_f_z
  790. fmt 2 tip_dia
  791. fmt 2 min_dia
  792. fmt 2 thd_ang
  793.  
  794. fmt 2 pilot_dia # 20007 Parameter line
  795. fmt H 2 flute_len
  796. fmt 2 oa_len
  797. fmt 2 shldr_len
  798. fmt 2 arbor_dia
  799. fmt 2 hldr_dia
  800. fmt 2 hldr_len
  801. fmt 2 spindle_ccw
  802. fmt 2 sfm
  803. fmt 2 fpt
  804. fmt 2 metric
  805.  
  806. fmt 2 stock # Amount of Stock left on drive surfs
  807. fmt 2 check # Amount of Stock left on check surfs
  808. fmt S 4 cyl_typ # Predator Cylindral Stock Type
  809. fmt L 2 stck_ht$
  810. fmt W 2 stck_wdth$
  811. fmt H 2 stck_thck$
  812. fmt D 2 stck_diam
  813. fmt X 2 stck_x$
  814. fmt Y 2 stck_y$
  815. fmt Z 2 stck_z$
  816. fmt X 2 stck_x_min
  817. fmt Y 2 stck_y_min
  818. fmt Z 2 stck_z_min
  819.  
  820. fmt X 2 stck_meta_ht
  821. fmt Y 2 stck_meta_wdth
  822. fmt Z 2 stck_meta_thck
  823. fmt OX 2 stck_meta_ox
  824. fmt OY 2 stck_meta_oy
  825. fmt OZ 2 stck_meta_oz
  826.  
  827. fmt X 2 x_tmin # Total x_min
  828. fmt X 2 x_tmax # Total x_max
  829. fmt Y 2 y_tmin # Total y_min
  830. fmt Y 2 y_tmax # Total y_max
  831. fmt Z 2 z_tmin # Total z_min
  832. fmt Z 2 z_tmax # Total z_max
  833. fmt Z 2 min_depth # Tool z_min
  834. fmt Z 2 max_depth # Tool z_max
  835.  
  836. fmt 2 vers_no$ # Mastercam version
  837. fmt 2 m_vers_no$ # Minor version number
  838. fmt 2 dll_vers$ # Mp.dll version
  839.  
  840. # --------------------------------------------------------------------------
  841. # Tool Comment / Manual Entry Section
  842. # --------------------------------------------------------------------------
  843. ptoolcomment #Comment for tool
  844. tnote = t$
  845. toffnote = tloffno$
  846. tlngnote = tlngno$
  847. tldianote = tldia$
  848. "(",pstrtool, *tnote, *tldianote,")", e$
  849.  
  850.  
  851. pstrtool #Comment for tool
  852. if strtool$ <> sblank,
  853. [
  854. strtool$ = ucase(strtool$)
  855. *strtool$, " "
  856. ]
  857.  
  858. pcomment$ #Comment from manual entry (must call pcomment2 if booleans)
  859. pcomment2
  860.  
  861. pcomment2 #Comment from manual entry
  862. spaces$ = 0
  863. scomm$ = ucase (scomm$)
  864. #1005 - Comment option 1
  865. #1006 - Comment option 2
  866. #1007 - Define comment with output line
  867. #1008 - Define NC parameter comment
  868. #1026 - ?
  869. if gcode$ = 1005, pbld, n$, pspc, "(", scomm$, ")"
  870. if gcode$ = 1006, pbld, n$, pspc, "(", scomm$, ")" #Comments
  871. #if gcode = 1006, pbld, n, pspc, scomm #Codes
  872. if gcode$ = 1007, "(", scomm$, ")"
  873. if gcode$ >= 1008, pbld, n$, pspc, "(", scomm$, ")"
  874. if gcode$ = 1026, pbld, scomm$
  875. if gcode$ <> 1007 & gcode$ <> 1026, e$
  876. spaces$ = sav_spc
  877.  
  878. ptoolcomm # Comments from tool library
  879. spaces$ = 0
  880. strtool$=ucase(strtool$)
  881. if strtool$<>snull, "(",*strtool$,")", e$
  882. spaces$ = sav_spc
  883.  
  884. plistcomm # Comments from tool library
  885. strtool$=ucase(strtool$)
  886. if strtool$<>snull, *strtool$
  887.  
  888. if strtool$=snull, stest1=snocomm+stilde
  889. else, stest1=strtool$+stilde
  890. nstrlen = strstr(stilde,stest1)-1
  891. counter = 1
  892. while counter <= (18-nstrlen), pspace
  893.  
  894. pmetacomm # Comments from tool library
  895. strtool$=ucase(strtool$)
  896. if strtool$<>snull, *strtool$
  897.  
  898.  
  899. pspace # Creates spaces based on tool comment length
  900. " "
  901. counter = counter + 1
  902.  
  903. ptspace # Creates spaces based on tool number
  904. if t$<10, " "
  905.  
  906. phspace # Creates spaces based on length offset number
  907. if tlngno$<10, " "
  908.  
  909. pdspace # Creates spaces based on diameter offset number
  910. if tloffno$<10, " "
  911.  
  912. pdiamspc # Creates spaces based on diameter offset number
  913. if tldia$<10, " "
  914.  
  915. pspc # Creates spaces based tool level setting
  916. if sav_spc = one & omitseq$ = yes$, " "
  917.  
  918. pspc1 # Creates spaces based tool level setting
  919. if sav_spc = one, " "
  920.  
  921. popnote # Operation note for tool table
  922. if opcode$ = 3, *sdrnote
  923. else, *sopnote
  924.  
  925. pstock # Comment amount of stock to leave
  926. spaces$=0
  927. if (opcode$=13 | opcode$=14),
  928. [
  929. pbld, n$, pspc, "(TOOLPATH-", *stoper,")", e$
  930. pbld, n$, pspc, "(STOCK LEFT ON DRIVE SURFS = ", *stock, ")", e$
  931. if check<>0, pbld, n$, pspc, "(STOCK LEFT ON CHECK SURFS = ", *check, ")", e$
  932. ]
  933. spaces$=sav_spc
  934.  
  935. ppredstck # Predator stock
  936. spaces$=0
  937. q1
  938. if stock_typ = 1,
  939. [
  940. cyl_typ = rot_on_x
  941. q2
  942. ]
  943. if stock_typ = 0, ppredbox
  944. if stock_typ = 1,
  945. [
  946. if cyl_typ = 1, ppredcylx
  947. if cyl_typ = 2, ppredcyly
  948. if cyl_typ = 3, ppredcylz
  949. ]
  950. spaces$=sav_spc
  951.  
  952. ppredbox # Predator Box Stock
  953. if stck_crnr$ = 0,
  954. [
  955. stck_x_min = stck_x$ - stck_ht$/2
  956. stck_y_min = stck_y$ - stck_wdth$/2
  957. ]
  958. if stck_crnr$ = 1 | stck_crnr$ = 5,
  959. [
  960. stck_x_min = stck_x$
  961. stck_y_min = stck_y$ - stck_wdth$
  962. ]
  963. if stck_crnr$ = 2 | stck_crnr$ = 6,
  964. [
  965. stck_x_min = stck_x$ - stck_ht$
  966. stck_y_min = stck_y$ - stck_wdth$
  967. ]
  968. if stck_crnr$ = 3 | stck_crnr$ = 7,
  969. [
  970. stck_x_min = stck_x$ - stck_ht$
  971. stck_y_min = stck_y$
  972. ]
  973. if stck_crnr$ = 4 | stck_crnr$ = 8,
  974. [
  975. stck_x_min = stck_x$
  976. stck_y_min = stck_y$
  977. ]
  978. if stck_crnr$ <= 4, stck_z_min = stck_z$ - stck_thck$
  979. else, stck_z_min = stck_z$
  980.  
  981. "(SBOX ", *stck_x_min, " ", *stck_y_min, " ", *stck_z_min, " ", *stck_ht$, " ", *stck_wdth$, " ", *stck_thck$, ")"
  982.  
  983. ppredcylx # Predator Cyl-X Stock
  984. if stck_crnr$ = 0,
  985. [
  986. stck_x_min = stck_x$ - stck_ht$/2
  987. stck_y_min = stck_y$
  988. ]
  989. if stck_crnr$ = 1 | stck_crnr$ = 5,
  990. [
  991. stck_x_min = stck_x$
  992. stck_y_min = stck_y$ - stck_wdth$/2
  993. ]
  994. if stck_crnr$ = 2 | stck_crnr$ = 6,
  995. [
  996. stck_x_min = stck_x$ - stck_ht$
  997. stck_y_min = stck_y$ - stck_wdth$/2
  998. ]
  999. if stck_crnr$ = 3 | stck_crnr$ = 7,
  1000. [
  1001. stck_x_min = stck_x$ - stck_ht$
  1002. stck_y_min = stck_y$ + stck_wdth$/2
  1003. ]
  1004. if stck_crnr$ = 4 | stck_crnr$ = 8,
  1005. [
  1006. stck_x_min = stck_x$
  1007. stck_y_min = stck_y$ + stck_wdth$/2
  1008. ]
  1009. if stck_crnr$ <= 4, stck_z_min = stck_z$ - stck_thck$/2
  1010. else, stck_z_min = stck_z$ + stck_thck$/2
  1011.  
  1012. stck_diam = stck_wdth$
  1013. if stck_thck$ > stck_wdth$, stck_diam = stck_thck$
  1014. stck_ht$ = stck_ht$
  1015. "(SCYL ", *cyl_typ, " ", *stck_x_min, " ", *stck_y_min, " ", *stck_z_min, " ", *stck_diam, " ", *stck_ht$, ")"
  1016.  
  1017. ppredcyly # Predator Cyl-Y Stock
  1018. if stck_crnr$ = 0,
  1019. [
  1020. stck_x_min = stck_x$
  1021. stck_y_min = stck_y$ - stck_wdth$/2
  1022. ]
  1023. if stck_crnr$ = 1 | stck_crnr$ = 5,
  1024. [
  1025. stck_x_min = stck_x$ + stck_ht$/2
  1026. stck_y_min = stck_y$ - stck_wdth$
  1027. ]
  1028. if stck_crnr$ = 2 | stck_crnr$ = 6,
  1029. [
  1030. stck_x_min = stck_x$ - stck_ht$/2
  1031. stck_y_min = stck_y$ - stck_wdth$
  1032. ]
  1033. if stck_crnr$ = 3 | stck_crnr$ = 7,
  1034. [
  1035. stck_x_min = stck_x$ - stck_ht$/2
  1036. stck_y_min = stck_y$
  1037. ]
  1038. if stck_crnr$ = 4 | stck_crnr$ = 8,
  1039. [
  1040. stck_x_min = stck_x$ + stck_ht$/2
  1041. stck_y_min = stck_y$
  1042. ]
  1043. if stck_crnr$ <= 4, stck_z_min = stck_z$ - stck_thck$/2
  1044. else, stck_z_min = stck_z$ + stck_thck$/2
  1045.  
  1046. stck_diam = stck_ht$
  1047. if stck_thck$ > stck_ht$, stck_diam = stck_thck$
  1048. stck_ht$ = stck_wdth$
  1049. "(SCYL ", *cyl_typ, " ", *stck_x_min, " ", *stck_y_min, " ", *stck_z_min, " ", *stck_diam, " ", *stck_ht$, ")"
  1050.  
  1051. ppredcylz # Predator Cyl-Z Stock
  1052. if stck_crnr$ = 0,
  1053. [
  1054. stck_x_min = stck_x$
  1055. stck_y_min = stck_y$
  1056. ]
  1057. if stck_crnr$ = 1 | stck_crnr$ = 5,
  1058. [
  1059. stck_x_min = stck_x$ + stck_ht$/2
  1060. stck_y_min = stck_y$ - stck_wdth$/2
  1061. ]
  1062. if stck_crnr$ = 2 | stck_crnr$ = 6,
  1063. [
  1064. stck_x_min = stck_x$ - stck_ht$/2
  1065. stck_y_min = stck_y$ - stck_wdth$/2
  1066. ]
  1067. if stck_crnr$ = 3 | stck_crnr$ = 7,
  1068. [
  1069. stck_x_min = stck_x$ - stck_ht$/2
  1070. stck_y_min = stck_y$ + stck_wdth$/2
  1071. ]
  1072. if stck_crnr$ = 4 | stck_crnr$ = 8,
  1073. [
  1074. stck_x_min = stck_x$ + stck_ht$/2
  1075. stck_y_min = stck_y$ + stck_wdth$/2
  1076. ]
  1077. if stck_crnr$ <= 4, stck_z_min = stck_z$ - stck_thck$
  1078. else, stck_z_min = stck_z$
  1079.  
  1080. stck_diam = stck_ht$
  1081. if stck_wdth$ > stck_ht$, stck_diam = stck_wdth$
  1082. stck_ht$ = stck_thck$
  1083. "(SCYL ", *cyl_typ, " ", *stck_x_min, " ", *stck_y_min, " ", *stck_z_min, " ", *stck_diam, " ", *stck_ht$, ")"
  1084.  
  1085. pmetastck # MetaCut View stock
  1086. if stck_crnr$ = 0,
  1087. [
  1088. stck_meta_ox = stck_x$ * m_one - (tox$ * m_one)
  1089. stck_meta_oy = stck_y$ * m_one - (toy$ * m_one)
  1090. ]
  1091. if stck_crnr$ = 1 | stck_crnr$ = 5,
  1092. [
  1093. stck_meta_ox = (stck_x$ + stck_ht$/2) * m_one - (tox$ * m_one)
  1094. stck_meta_oy = (stck_y$ - stck_wdth$/2) * m_one - (toy$ * m_one)
  1095. ]
  1096. if stck_crnr$ = 2 | stck_crnr$ = 6,
  1097. [
  1098. stck_meta_ox = (stck_x$ - stck_ht$/2) * m_one - (tox$ * m_one)
  1099. stck_meta_oy = (stck_y$ - stck_wdth$/2) * m_one - (toy$ * m_one)
  1100. ]
  1101. if stck_crnr$ = 3 | stck_crnr$ = 7,
  1102. [
  1103. stck_meta_ox = (stck_x$ - stck_ht$/2) * m_one - (tox$ * m_one)
  1104. stck_meta_oy = (stck_y$ + stck_wdth$/2) * m_one - (toy$ * m_one)
  1105. ]
  1106. if stck_crnr$ = 4 | stck_crnr$ = 8,
  1107. [
  1108. stck_meta_ox = (stck_x$ + stck_ht$/2) * m_one - (tox$ * m_one)
  1109. stck_meta_oy = (stck_y$ + stck_wdth$/2) * m_one - (toy$ * m_one)
  1110. ]
  1111. if stck_crnr$ <= 4, stck_meta_oz = stck_z$ * m_one - (toz$ * m_one)
  1112. else, stck_meta_oz = (stck_z$ + stck_thck$) * m_one - (toz$ * m_one)
  1113.  
  1114. stck_meta_ht = stck_ht$
  1115. stck_meta_wdth = stck_wdth$
  1116. stck_meta_thck = stck_thck$
  1117.  
  1118. #(NWDSTOCK X8. Y8. Z1.25 OTC OX-4. OY-4. OZ0.)
  1119. spaces$=0
  1120. "(NWDSTOCK ", *stck_meta_ht, " ", *stck_meta_wdth, " ", *stck_meta_thck,
  1121. " OTC ", *stck_meta_ox, " ", *stck_meta_oy, " ", *stck_meta_oz, ")"
  1122. spaces$=sav_spc
  1123.  
  1124. pstop # Stop routine
  1125. pretract
  1126. pcom_moveb, e$
  1127. if mi10$=one, n$, *sm00, e$
  1128. sav_absinc = absinc$
  1129. if wcstype > one, absinc$ = zero
  1130. comment$
  1131. if lock_codes = 1 & not(index) & rot_on_x, pbld, n$, *sunlock, "(UNLOCK)", e$
  1132. pcan1, pbld,*sgcode, *sgabsinc, pwcs, pfxout, pfyout,
  1133. pfcout, *speed, *spindle, pgear, strcantext, e$
  1134. if lock_codes = 1 & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1135. pbld, n$, "G43", *tlngno$, pfzout, scoolant,e$
  1136. next_tool$, e$
  1137. "G00",pfxout, pfyout,e$
  1138. sav_coolant = coolant$
  1139. if coolant$ = 1, sm09 = sm09_0
  1140. if coolant$ = 2, sm09 = sm09_1
  1141. if coolant$ = 3, sm09 = sm09_2
  1142. absinc$ = sav_absinc
  1143.  
  1144. # --------------------------------------------------------------------------
  1145. # Misc. Output
  1146. # --------------------------------------------------------------------------
  1147. pparameter$ # Run parameter table
  1148. if opcode$=13 | opcode$=14, result = fprm (opcode$)
  1149. if prmcode$ = 10000, stoper = ucase(sparameter$)
  1150. if prmcode$ = 10055, spostname = ucase(sparameter$)
  1151. #CNC<<MSG-ERROR(1150)>> Mastercam MP postblock 파라미터 문제 :파라미터 번호10055 삭제 된
  1152. #CNC<<MSG-ERROR(1150)>> 데이터 위치를 참조pre-X3 ASCII NCI information
  1153. #CNC<<MSG-ERROR(1150)>> 매개 변수 참조 설명서를 참조하거나 게시물을 수정 또는 교체에 대해 귀하의 마스터 캠 대리점에 문의
  1154. if stoper=snull, stoper = snullop
  1155.  
  1156. pwrttparam$ #Information from parameters
  1157. if prmcode$ = 20004, slot = rpar(sparameter$, 16)
  1158. if prmcode$ = 20006, cut_ability = rpar(sparameter$,8)
  1159. if prmcode$ = 20007, pilot_dia = rpar(sparameter$, 11)
  1160.  
  1161. # --------------------------------------------------------------------------
  1162. # Start of File and Toolchange Setup
  1163. # --------------------------------------------------------------------------
  1164. psof0$ #Start of file for tool zero
  1165. psof$
  1166.  
  1167. psof$ #Start of file for non-zero tool number
  1168. ptravel
  1169. pwritbuf5
  1170. pcuttype
  1171. toolchng = one
  1172. if ntools$ = one,
  1173. [
  1174. #skip single tool outputs, stagetool must be on
  1175. #stagetool = m_one
  1176. !next_tool$
  1177. ]
  1178.  
  1179. tooltotal = rbuf(4,0) #Reads total tool and null tool changes
  1180. if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
  1181. else, nexttool = first_tool$
  1182.  
  1183. if tool_table = 2, ppredstck,e$
  1184. if tool_table = 3, pmetastck,e$
  1185.  
  1186. spaces$=0
  1187. if output_z = yes$ & tcnt > 1,
  1188.  
  1189. spaces$=sav_spc
  1190. if plane$ < 0, plane$ = 0
  1191. pbld, *sgcode, *sgplane, "G40", "G80", *sgabsinc, e$
  1192. "G91G28Z0", e$
  1193. " ", e$
  1194. pbld, n$ , "G90G80G49G40", e$
  1195. n$, *n$, e$
  1196. if stagetool >=zero, pbld, n$, *t$,"M6", "(",pstrtool,")", e$
  1197.  
  1198. "M01 ", e$
  1199.  
  1200. if plane$ < 0, plane$ = 0
  1201. # pbld, n, *sgabsinc, *sgcode, e
  1202. sav_absinc = absinc$
  1203. if wcstype <= one, #Work coordinate system
  1204. [
  1205. absinc$ = one
  1206. pfbld, n$, sgabsinc, "G28", "Z0.", e$
  1207. pfbld, n$, "G92", *xh$, *yh$, *zh$, e$
  1208. absinc$ = sav_absinc
  1209. ]
  1210. sav_mi9 = mi9$
  1211. sav_workofs = workofs$
  1212. if sav_workofs < 0, sav_workofs = 0
  1213. ptlchg_com
  1214.  
  1215. ptlchg_com #Tool change common blocks
  1216. pcom_moveb
  1217. c_mmlt$ #Multiple tool subprogram call
  1218. #ptoolcomment
  1219. comment$
  1220. pcan
  1221.  
  1222. if output_z = yes$,
  1223. [
  1224. preadbuf5
  1225. if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,
  1226. [
  1227. n$, pspc, "(", "MAX - ", *max_depth, ")", e$
  1228. n$, pspc, "(", "MIN - ", *min_depth, ")", e$
  1229. ]
  1230. ]
  1231. spaces$=sav_spc
  1232. pstock
  1233. pindex
  1234. sav_absinc = absinc$
  1235. if wcstype > one, absinc$ = zero
  1236. if lock_codes = 1 & not(index) & rot_on_x, pbld, n$, *sunlock, "(UNLOCK)", e$
  1237. pcan1, pbld, n$, *sgabsinc,*sgcode, pwcs, pfxout, pfyout,
  1238. pfcout, *speed, *spindle, pgear, strcantext, e$
  1239. if lock_codes = 1 & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1240. pbld, n$, "G43", *tlngno$, pfzout,scoolant, e$
  1241. next_tool$, e$
  1242. "G00",pfxout, pfyout,e$
  1243. sav_coolant = coolant$
  1244. if coolant$ = 1, sm09 = sm09_0
  1245. if coolant$ = 2, sm09 = sm09_1
  1246. if coolant$ = 3, sm09 = sm09_2
  1247. absinc$ = sav_absinc
  1248. pcom_movea
  1249. toolchng = zero
  1250. c_msng$ #Single tool subprogram call
  1251. last_op_id = op_id$
  1252. last_cuttype = cuttype
  1253.  
  1254. ptlchg0$ #Call from NCI null tool change (tool number repeats)
  1255. pcuttype
  1256. pcom_moveb
  1257. toolcount = toolcount + 1
  1258. prvtp = rbuf(3,toolcountp)
  1259. if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
  1260. else, nexttool = first_tool$
  1261. if mi10$=one & op_id$<>last_op_id | (tlplnno$ <> prvtp & ret_on_indx), pstop
  1262. c_mmlt$ #Multiple tool subprogram call
  1263. comment$
  1264. pcan
  1265. if plane$ < 0, plane$ = 0
  1266. pbld, n$, sgplane, e$
  1267. pspindchng
  1268. if coolant$ <> 0 & coolant$ <> sav_coolant & sav_coolant, pbld, n$, sm09, e$
  1269. pbld, n$, scoolant, e$
  1270. sav_coolant = coolant$
  1271. if coolant$ = 1, sm09 = sm09_0
  1272. if coolant$ = 2, sm09 = sm09_1
  1273. if coolant$ = 3, sm09 = sm09_2
  1274. if op_id$<>last_op_id, pstock
  1275. if sav_mi9 = 1, workofs$ = sav_workofs
  1276. if (wcstype > one & workofs$ <> prv_workofs$) | (tlplnno$ <> prvtp),
  1277. [
  1278. sav_absinc = absinc$
  1279. absinc$ = zero
  1280. if fmtrnd(prv_cabs) <> fmtrnd(cabs),
  1281. [
  1282. if lock_codes = 1 & not(index) & rot_on_x, pbld, n$, *sunlock, "(UNLOCK)", e$
  1283. pbld, n$, sgabsinc, pwcs, pfxout, pfyout, pfzout, pfcout, e$
  1284. if lock_codes = 1 & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1285. ]
  1286. else,
  1287. [
  1288. pbld, n$, sgabsinc, pwcs, pfxout, pfyout, pfzout, pcout, e$
  1289. ]
  1290. pe_inc_calc
  1291. ps_inc_calc
  1292. absinc$ = sav_absinc
  1293. ]
  1294. if lock_codes = 1 & cuttype <> last_cuttype & cuttype > 0, pbld, n$, *sunlock, "(UNLOCK)", e$
  1295. if cuttype = zero, ppos_cax_lin
  1296. if lock_codes = 1 & cuttype <> last_cuttype & cuttype = 0 & fmtrnd(prv_cabs) = fmtrnd(cabs), pbld, n$, *slock, "(LOCK)", e$
  1297. if gcode$ = one, plinout
  1298. else, prapidout
  1299. pcom_movea
  1300. c_msng$ #Single tool subprogram call
  1301. last_op_id = op_id$
  1302. last_cuttype = cuttype
  1303.  
  1304. ptlchg$ #Tool change
  1305. pcuttype
  1306. toolchng = one
  1307. toolcount = toolcount + 1
  1308. if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
  1309. else, nexttool = first_tool$
  1310. if wcstype = one, #Work coordinate system
  1311. [
  1312. pfbld, n$, "G92", *xh$, *yh$, *zh$, e$
  1313. ]
  1314. pbld, n$, *sm01, e$
  1315. " ", e$
  1316. pbld, n$ , "G90G80G49G40", e$
  1317. n$, *n$, e$
  1318. if stagetool >=zero, pbld, n$,*t$,"M6","(",pstrtool,")", e$
  1319. "M01 ", e$
  1320.  
  1321. if mi10$=one, n$, *sm00, e$
  1322. ptlchg_com
  1323.  
  1324. pretract #End of tool path, toolchange
  1325. sav_absinc = absinc$
  1326. absinc$ = one
  1327. sav_coolant = coolant$
  1328. coolant$ = zero
  1329. #cc_pos is reset in the toolchange here
  1330. cc_pos$ = zero
  1331. gcode$ = zero
  1332.  
  1333. pbld, n$, sgabsinc, sgcode, "G28", "Z0.", "M5", scoolant, e$
  1334. #if lock_codes = 1 & rot_on_x, pbld, n, *sunlock, "(UNLOCK)", e
  1335. #pbld, n, "G90", "G00", "X800.", "Y500.", protretinc, e
  1336. #if lock_codes = 1 & rot_on_x & cuttype = 0, pbld, n, *slock, "(LOCK)", e
  1337. if abs(cabs) > 360 & nextop$ <> 1003,
  1338. [
  1339. if lock_codes = 1, pbld, n$, *sunlock, "(UNLOCK)", e$
  1340. rotretflg = 1
  1341. pbld, n$, 'G28', "M5", e$
  1342. rotretflg = 0
  1343. if lock_codes = 1 & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1344. ]
  1345. absinc$ = sav_absinc
  1346. coolant$ = sav_coolant
  1347.  
  1348. protretinc #Reset the C axis revolution counter
  1349. if frc_cinit & rot_on_x,
  1350. [
  1351. rev = zero
  1352. sav_rev = zero
  1353. cabs = zero
  1354. csav = zero
  1355. indx_out = zero
  1356. if index, e$, pindxcalc, pindex
  1357. else, *cabs
  1358. prvcabs = zero
  1359. !csav, !cabs
  1360. ]
  1361.  
  1362. peof0$ #End of file for tool zero
  1363. peof$
  1364.  
  1365. peof$ #End of file for non-zero tool
  1366. pretract
  1367. if lock_codes = 1 & rot_on_x, pbld, n$, *sunlock, "(UNLOCK)",
  1368. rotretflg = 1
  1369. pbld, n$, "G91 G28 Y0.", e$
  1370. rotretflg = 0
  1371. if lock_codes = 1 & rot_on_x, pbld, n$, *slock, "(LOCK)",
  1372. comment$,e$
  1373. #Remove pound character to output first tool with staged tools
  1374. #if stagetool = one, pbld, n, *first_tool, e
  1375. # n, *sg90, e
  1376. #n$, "G90 G00 X0.", e$
  1377. n$, "M30", e$
  1378. mergesub$
  1379. clearsub$
  1380. mergeaux$
  1381. clearaux$
  1382. "%", e$
  1383.  
  1384. #If posting to Deskop, or other long dir path names, this logic will crash Mastercam
  1385. #snci = spathnci + snamenci + sextnci
  1386. #sparams1 = ssq + sdq + snci + sdq + sspace + sdq + spathpst + spost1 + sdq + sspace + sdq + spathnc + sdq + ssq
  1387.  
  1388. #ppost #Called after posting is complete and all files are closed
  1389. #result = fexist(sdll)
  1390. #if result = 1, result = dll(sdll,sparams1)
  1391.  
  1392. pwcs #G55+ coordinate setting at toolchange
  1393. if wcstype = two | wcstype > three,
  1394. [
  1395. sav_frc_wcs = force_wcs
  1396. if sub_level$ > 0, force_wcs = zero
  1397. if sav_mi9 = 1, workofs$ = sav_workofs
  1398. if workofs$ < 0, workofs$ = 0
  1399. if workofs$ <> prv_workofs$ | (force_wcs & toolchng),
  1400. [
  1401. if workofs$ < 6,
  1402. [
  1403. g_wcs = workofs$ + 54
  1404. *g_wcs
  1405. ]
  1406. else,
  1407. [
  1408. p_wcs = workofs$ - five
  1409. "G54.1", *p_wcs
  1410. ]
  1411. ]
  1412. force_wcs = sav_frc_wcs
  1413. !workofs$
  1414. ]
  1415.  
  1416. pgear #Find spindle gear from lookup table
  1417. if use_gear = one,
  1418. [
  1419. gear = frange (one, speed)
  1420. *gear
  1421. ]
  1422.  
  1423. #Toolchange setup
  1424. pspindchng #Spindle speed change
  1425. if prv_spdir2 <> spdir2 & prv_speed <> zero, pbld, n$, *sm05, e$
  1426. if prv_speed <> speed | prv_spdir2 <> spdir2,
  1427. [
  1428. if speed, pbld, n$, *speed, *spindle, pgear, e$
  1429. ]
  1430. !speed, !spdir2
  1431.  
  1432. pspindle #Spindle speed calculations for RPM
  1433. speed = abs(ss$)
  1434. if maxss$ = zero | maxss$ > max_speed, maxss$ = max_speed
  1435. #zero indicates spindle off (not a mistake)
  1436. if speed,
  1437. [
  1438. if speed > max_speed, speed = maxss$
  1439. if speed < min_speed, speed = min_speed
  1440. ]
  1441. spdir2 = fsg3(spdir$)
  1442.  
  1443. pq$ #Setup post based on switch settings
  1444. sav_spc = spaces$
  1445. if stagetool = one, bldnxtool$ = one
  1446. #Rotaxtyp = 1 sets initial matrix to top
  1447. #Rotaxtyp = -2 sets initial matrix to front
  1448. if vmc, rotaxtyp$ = one
  1449. else, rotaxtyp$ = -2
  1450. #Shut off rotary axis if, Q164. Enable Rotary Axis button? n
  1451. if ucase(sq164) = strn, rot_on_x = zero
  1452. if arctype$ = one | arctype$ = four,
  1453. [
  1454. result = newfs(two, i$)
  1455. result = newfs(two, j$)
  1456. result = newfs(two, k$)
  1457. ]
  1458. else,
  1459. [
  1460. result = newfs(three, i$)
  1461. result = newfs(three, j$)
  1462. result = newfs(three, k$)
  1463. ]
  1464. if usecanned = yes$, pusecannedyes
  1465. else, pusecannedno
  1466.  
  1467. pheader$ #Call before start of file
  1468. if met_tool$ = one, #Metric constants and variable adjustments
  1469. [
  1470. ltol$ = ltol_m
  1471. vtol$ = vtol_m
  1472. maxfeedpm = maxfeedpm_m
  1473. ]
  1474. result = nwadrs(srotary, cabs)
  1475. result = nwadrs(srotary, cinc)
  1476. result = nwadrs(srotary, indx_out)
  1477.  
  1478. "%" , e$
  1479. "O0001" ,e$
  1480.  
  1481. "(KIM JIN WOONG)",e$
  1482. "( ", sprogname$,")",e$
  1483. spathnc$ = ucase(spathnc$)
  1484. smcname$ = ucase(smcname$) , e$
  1485. #"(MASTERCAM - V", *vers_no, ")", e
  1486. #"(MC9 FILE - ", smcpath, smcname, smcext, ")", e
  1487. #"(POST - ", spostname, ")", e
  1488. #"(MP - v", *dll_vers, ")", e
  1489. #stck_matl = ucase(stck_matl)
  1490. #"(MATERIAL - ", stck_matl, ")", e
  1491. #"(PROGRAM - ", sprogname, sextnc, ")", e
  1492. "(DATE = ","20",year$ , "-", *smonth, "-", day$ , ")", e$
  1493. #"(TIME - ", *time, ")", e
  1494. #"(POST DEV - ", *slicense, ")", e
  1495. spaces$=sav_spc
  1496.  
  1497. if seqno$ = 1, omitseq$ = yes$
  1498. sav_rot_on_x = rot_on_x
  1499. rot_on_x = 0
  1500. sav_progno = progno$
  1501.  
  1502. seqno$ =1.
  1503. seqinc$ =1
  1504. n$ = seqno$
  1505.  
  1506. ptoolend$ #End of tool path, before reading new tool data
  1507. !speed, !spdir2
  1508.  
  1509. ptlchg1002$ #Call at actual toolchange, end last path here
  1510. if op_id$ <> last_op_id,
  1511. [
  1512. #if cuttype <> one, sav_rev = rev #Axis Sub does not update to rev # CNC Mpfan V9.1
  1513. sav_rev = rev #Axis Sub does not update to rev
  1514. if one_rev = one | workofs$ <> prv_workofs$, sav_rev = 0
  1515. ]
  1516. pspindle
  1517. whatline$ = four #Required for vector toolpaths
  1518. if gcode$ = 1000,
  1519. [
  1520. #Null toolchange
  1521. ]
  1522. else,
  1523. [
  1524. #Toolchange and Start of file
  1525. if gcode$ = 1002,
  1526. [
  1527. #Actual toolchange
  1528. pretract
  1529. ]
  1530. if stagetool = one, prv_next_tool$ = m_one
  1531. prv_xia = vequ(xh$)
  1532. prv_feed = c9k
  1533. ]
  1534.  
  1535. # --------------------------------------------------------------------------
  1536. # Motion NC output
  1537. # --------------------------------------------------------------------------
  1538. #The variables for absolute output are xabs, yabs, zabs.
  1539. #The variables for incremental output are xinc, yinc, zinc.
  1540. # --------------------------------------------------------------------------
  1541. prapidout #Output to NC of linear movement - rapid
  1542. pcan1, pbld, n$, sgplane, `sgcode, sgabsinc, pccdia,
  1543. pxout, pyout, pzout, pcout, strcantext, scoolant, e$
  1544.  
  1545. plinout #Output to NC of linear movement - feed
  1546. pcan1, pbld, n$, sgfeed, sgplane, `sgcode, sgabsinc, pccdia,
  1547. pxout, pyout, pzout, pcout, `feed, strcantext, scoolant, e$
  1548.  
  1549. pcirout #Output to NC of circular interpolation
  1550. if compwarn, pcompwarn
  1551. if hel_2100 = one, pcirout2
  1552. else, pcirout1
  1553.  
  1554. pcirout1 #Output to NC of circular interpolation
  1555. pcan1, pbld, n$, `sgfeed, sgplane, sgcode, sgabsinc, pccdia,
  1556. pxout, pyout, pzout, pcout, parc, feed, strcantext, scoolant, e$
  1557.  
  1558. pcirout2 #Output to NC of circular interpolation
  1559. if (plane$ = zero & abs(zinc)>=0.0005)
  1560. | (plane$ = one & abs(xinc)>=0.0005)
  1561. | (plane$ = two & abs(yinc)>=0.0005), phelout
  1562. else, pcirout1
  1563.  
  1564. phelout #Output to NC of helical interpolation
  1565. if plane$ = zero,
  1566. [
  1567. result = nwadrs(strk, lead)
  1568. lead = abs(zinc/sweep$*360)
  1569. ]
  1570. if plane$ = one,
  1571. [
  1572. result = nwadrs(stri, lead)
  1573. lead = abs(xinc/sweep$*360)
  1574. ]
  1575. if plane$ = two,
  1576. [
  1577. result = nwadrs(strj, lead)
  1578. lead = abs(yinc/sweep$*360)
  1579. ]
  1580. pcan1, pbld, n$, `sgfeed, sgplane, sgcode, sgabsinc, pccdia,
  1581. pxout, pyout, pzout, *lead, pcout, parc, feed, strcantext, scoolant, e$
  1582.  
  1583. pcom_moveb #Common motion preparation routines, before
  1584. pxyzcout
  1585. ps_inc_calc
  1586.  
  1587. pncoutput #Movement output
  1588. pcom_moveb
  1589. comment$
  1590. if coolant$ <> 0 & coolant$ <> sav_coolant,
  1591. [
  1592. pbld, n$,e$
  1593. sm09, e$
  1594. sav_coolant = coolant$
  1595. ]
  1596. if coolant$ = 1, sm09 = sm09_0
  1597. if coolant$ = 2, sm09 = sm09_1
  1598. if coolant$ = 3, sm09 = sm09_2
  1599. if cool_zmove = yes$ & (nextop$=1003 | (nextop$=1011 & t$<>abs(nexttool))), coolant$ = zero
  1600. pcan
  1601. if cuttype = zero, ppos_cax_lin #Toolplane rotary positioning
  1602. if gcode$ = zero, prapidout
  1603. if gcode$ = one, plinout
  1604. if gcode$ > one & gcode$ < four, pcirout
  1605. if mr_rt_actv, #Restore absolute/incremental for G51/G68
  1606. [
  1607. absinc$ = sav_absinc
  1608. mr_rt_actv = zero
  1609. ]
  1610. pcom_movea
  1611.  
  1612. pcom_movea #Common motion preparation routines, after
  1613. pcan2
  1614. pe_inc_calc
  1615.  
  1616. pdwl_spd$ #Call from NCI gcode 4
  1617. pspindle
  1618. comment$
  1619. pspindchng
  1620. pcan
  1621. if fmtrnd(dwell$), pcan1, pbld, n$, *sgcode, *dwell$, strcantext, e$
  1622. else, pcan1, pbld, n$, strcantext, e$
  1623. pcan2
  1624.  
  1625. prapid$ #Output to NC of linear movement - rapid
  1626. pncoutput
  1627.  
  1628. pzrapid$ #Output to NC of linear movement - rapid Z only
  1629. pncoutput
  1630.  
  1631. plin$ #Output to NC of linear movement - feed
  1632. pncoutput
  1633.  
  1634. pz$ #Output to NC of linear movement - feed Z only
  1635. pncoutput
  1636.  
  1637. pmx$ #Output to NC of vector NCI
  1638. pncoutput
  1639.  
  1640. pcir$ #Output to NC of circular interpolation
  1641. pncoutput
  1642.  
  1643. #Pre-process rotary motion control flags
  1644. pmx0$ #5 axis gcode setup
  1645. if drillcur$ = zero,
  1646. [
  1647. if fr$ = -2, gcode$ = zero
  1648. else, gcode$ = one
  1649. ]
  1650.  
  1651. plin0$ #Linear movement, mill motion test
  1652. pmotion_su
  1653.  
  1654. pcir0$ #Circular interpolation, mill arc motion test
  1655. pmotion_su
  1656.  
  1657. # --------------------------------------------------------------------------
  1658. # Motion output components
  1659. # --------------------------------------------------------------------------
  1660. pbld #Canned text - block delete
  1661. if bld, '/'
  1662.  
  1663. pfbld #Force - block delete
  1664. "/"
  1665.  
  1666. pcompwarn #Cutter Compensation Check
  1667. if prv_cc_pos$ <> cc_pos$ & cc_pos$ & gcode$ > 1,
  1668. [
  1669. if compwarnflg = 0, result = mprint(scompwarn,1)
  1670. spaces$ = 0
  1671. pbld, n$, pspc, *sm00, pspc, "(", scompwarn, ")", e$
  1672. spaces$ = sav_spc
  1673. compwarnflg = 1
  1674. ]
  1675.  
  1676. pccdia #Cutter Compensation
  1677. #Force Dxx#
  1678. if prv_cc_pos$ <> cc_pos$ & cc_pos$, prv_tloffno$ = c9k
  1679. sccomp
  1680. if cc_pos$, tloffno$
  1681.  
  1682. pfxout #Force X axis output
  1683. if absinc$ = zero, *xabs, !xinc
  1684. else, *xinc, !xabs
  1685.  
  1686. pxout #X output
  1687. if absinc$ = zero, xabs, !xinc
  1688. else, xinc, !xabs
  1689.  
  1690. pfyout #Force Y axis output
  1691. if absinc$ = zero, *yabs, !yinc
  1692. else, *yinc, !yabs
  1693.  
  1694. pyout #Y output
  1695. if absinc$ = zero, yabs, !yinc
  1696. else, yinc, !yabs
  1697.  
  1698. pfzout #Force Z axis output
  1699. if absinc$ = zero, *zabs, !zinc
  1700. else, *zinc, !zabs
  1701.  
  1702. pzout #Z output
  1703. if absinc$ = zero, zabs, !zinc
  1704. else, zinc, !zabs
  1705.  
  1706. pfcout #Force C axis output
  1707. if index = zero & rot_on_x,
  1708. [
  1709. if absinc$ = zero, *cabs, !cinc
  1710. else, *cinc, !cabs
  1711. ]
  1712.  
  1713. pcout #C axis output
  1714. if index = zero & rot_on_x,
  1715. [
  1716. if absinc$ = zero, cabs, !cinc
  1717. else, cinc, !cabs
  1718. ]
  1719.  
  1720. pindex #Index output
  1721. if index & rot_on_x,
  1722. [
  1723. if fmtrnd(prv_indx_out) <> fmtrnd(indx_out),
  1724. [
  1725. if lock_codes = 1 & rotretflg = 0, pbld, n$, *sunlock, "(UNLOCK)", e$
  1726. pbld, n$, `sindx_mc, indx_out, e$
  1727. if lock_codes = 1 & cuttype = 0 & rotretflg = 0, pbld, n$, *slock, "(LOCK)", e$
  1728. ]
  1729. !cabs, !cinc
  1730. ]
  1731.  
  1732. parc #Select the arc output
  1733. if arcoutput$ = zero | full_arc_flg$ | arc_pitch$,
  1734. [
  1735. #Arc output for IJK
  1736. # If you do NOT want to force out the I,J,K values,
  1737. # remove the "*" asterisks on the *i, *j, *k 's below...
  1738. if plane$ = zero, *i$, *j$, k$ #XY plane code - G17
  1739. if plane$ = one, i$, *j$, *k$ #YZ plane code - G19
  1740. if plane$ = two, *i$, j$, *k$ #XZ plane code - G18
  1741. ]
  1742. else,
  1743. [
  1744. #Arc output for R
  1745. if abs(sweep$)<=180 | arcoutput$=one, result = nwadrs(srad, arcrad$)
  1746. else, result = nwadrs(srminus, arcrad$)
  1747. *arcrad$
  1748. ]
  1749.  
  1750. ppos_cax_lin #Position the rotary axis before move - rapid
  1751. if index, pindex
  1752. else,
  1753. [
  1754. if fmtrnd(prv_cabs) <> fmtrnd(cabs) & rot_on_x,
  1755. [
  1756. sav_gcode = gcode$
  1757. gcode$ = zero
  1758. if lock_codes = 1 & not(index), pbld, n$, *sunlock, "(UNLOCK)", e$
  1759. pbld, n$, sgcode, pcout, e$
  1760. if lock_codes = 1 & not(index) & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1761. !cia
  1762. ps_cinc_calc
  1763. gcode$ = sav_gcode
  1764. ]
  1765. ]
  1766.  
  1767. # --------------------------------------------------------------------------
  1768. # Drilling
  1769. # --------------------------------------------------------------------------
  1770. pdrill0$ #Pre-process before drill call
  1771. sav_dgcode = gcode$ #Capture gcode for 5 axis drill
  1772.  
  1773. pdrlcommonb #Canned Drill Cycle common call, before
  1774. if sav_dgcode = 81,
  1775. [
  1776. result = newfs (two, zinc)
  1777. if tap_feed = one & drillcyc$ = three, result = newfs (two, feed) #Tap feeds with 4/3 decimal places
  1778. if drillcyc$ = three, drlgsel = fsg1(-ss$) + drillcyc$ * two
  1779. else, drlgsel = fsg2(dwell$) + drillcyc$ * two
  1780. if initht$ <> refht$, drillref = zero
  1781. else, drillref = one
  1782. prv_refht_a = c9k
  1783. prv_refht_i = c9k
  1784. prv_dwell$ = zero
  1785. ]
  1786. if cuttype = three, sav_dgcode = gcode$
  1787. else, z$ = depth$
  1788. if cuttype = one, prv_zia = initht$ + (rotdia$/two)
  1789. else, prv_zia = refht$ #Fanuc style - G91 Z depth from R level
  1790. #else, prv_zia = initht #G91 Z depth from initial height
  1791. pcom_moveb
  1792. feed = fr_pos$
  1793. comment$
  1794. pcan
  1795. #5 axis must map the true Z, correct Z calculation here
  1796. if cuttype = three,
  1797. [
  1798. prv_zia = zabs + (-depth$) + initht$
  1799. zia = fmtrnd(zabs)
  1800. zinc = zia - prv_zia
  1801. ]
  1802. pbld, n$, sgabsinc, e$
  1803.  
  1804. prdrlout #R drill position
  1805. if cuttype = one, refht_a = refht$ + (rotdia$ / two)
  1806. else, refht_a = refht$
  1807. refht_i = refht$ - initht$
  1808. if cuttype = three, refht_a = w$
  1809. if absinc$ = zero, refht_a, !refht_i
  1810. else, refht_i, !refht_a
  1811.  
  1812. pdrlxy #Drill XY coordinates
  1813. if force_dpts, pfxout, pfyout
  1814. else, pxout, pyout
  1815.  
  1816. pdrill$ #Canned Drill Cycle
  1817. pdrlcommonb
  1818. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1819. prdrlout, dwell$, *feed, strcantext, e$
  1820. pcom_movea
  1821.  
  1822. ppeck$ #Canned Peck Drill Cycle
  1823. pdrlcommonb
  1824. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1825. prdrlout, *peck1$, *feed, strcantext, e$
  1826. pcom_movea
  1827.  
  1828. pchpbrk$ #Canned Chip Break Cycle
  1829. pdrlcommonb
  1830. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1831. prdrlout, *peck1$, *feed, strcantext, e$
  1832. pcom_movea
  1833.  
  1834. ptap$ #Canned Tap Cycle
  1835. pdrlcommonb
  1836. #RH/LH based on spindle direction
  1837. if use_pitch, pbld, n$, "G95", e$
  1838. if use_pitch = 0,
  1839. [
  1840. "M29",*speed,e$
  1841. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1842. prdrlout, *feed, strcantext, e$
  1843. ]
  1844. else,
  1845. [
  1846. if met_tool$, pitch = n_tap_thds$ # Tap pitch (mm per thread)
  1847. else, pitch = 1/n_tap_thds$ # Tap pitch (inches per thread)
  1848. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1849. prdrlout, *pitch, !feed, strcantext, e$
  1850. ]
  1851. pcom_movea
  1852. tapflg = 1
  1853.  
  1854. pbore1$ #Canned Bore #1 Cycle
  1855. pdrlcommonb
  1856. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1857. prdrlout, dwell$, *feed, strcantext, e$
  1858. pcom_movea
  1859.  
  1860. pbore2$ #Canned Bore #2 Cycle
  1861. pdrlcommonb
  1862. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1863. prdrlout, *feed, strcantext, e$
  1864. pcom_movea
  1865.  
  1866. pmisc1$ #Canned Misc #1 Cycle
  1867. pdrlcommonb
  1868. pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1869. prdrlout, shftdrl$, dwell$ , *feed, strcantext, e$
  1870. pcom_movea
  1871.  
  1872. pmisc2$ #Canned Misc #2 Cycle (User Option)
  1873. pdrill$
  1874.  
  1875. pdrill_2$ #Canned Drill Cycle, additional points
  1876. pdrlcommonb
  1877. pcan1, pbld, n$, pdrlxy, pzout, pcout, prdrlout, dwell$,
  1878. feed, strcantext, e$
  1879. pcom_movea
  1880.  
  1881. ppeck_2$ #Canned Peck Drill Cycle
  1882. pdrlcommonb
  1883. pcan1, pbld, n$, pdrlxy, pzout, pcout, prdrlout, feed, strcantext, e$
  1884. pcom_movea
  1885.  
  1886. pchpbrk_2$ #Canned Chip Break Cycle
  1887. pdrlcommonb
  1888. pcan1, pbld, n$, pdrlxy, pzout, pcout, prdrlout, feed, strcantext, e$
  1889. pcom_movea
  1890.  
  1891. ptap_2$ #Canned Tap Cycle
  1892. pdrill_2$
  1893.  
  1894. pbore1_2$ #Canned Bore #1 Cycle
  1895. pdrill_2$
  1896.  
  1897. pbore2_2$ #Canned Bore #2 Cycle
  1898. pdrill_2$
  1899.  
  1900. pmisc1_2$ #Canned Misc #1 Cycle
  1901. pdrill_2$
  1902.  
  1903. pmisc2_2$ #Canned Misc #2 Cycle
  1904. pdrill_2$
  1905.  
  1906. pdrlcst$ #Custom drill cycles 8 - 19 (user option)
  1907. #Use this postblock to customize drilling cycles 8 - 19
  1908. pdrlcommonb
  1909. #if drillcyc = 8, pcan1, pbld, n, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout,
  1910. # prdrlout, dwell, *feed, strcantext, e
  1911. if drillcyc$ = 8,
  1912. [
  1913. sub_prg_call = peck1$
  1914. pcan1, pbld, n$, *sg00, *sgabsinc, pfxout, pfyout, strcantext, e$
  1915. pbld, n$, "M98", *sub_prg_call, e$
  1916. ]
  1917. else, "CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, pfcout, e$
  1918. pcom_movea
  1919.  
  1920. pdrlcst_2$ #Custom drill cycles 8 - 19, additional points (user option)
  1921. #Use this postblock to customize drilling cycles 8 - 19
  1922. pdrlcommonb
  1923. #if drillcyc = 8, pcan1, pbld, n, pdrlxy, pzout, pcout, prdrlout, dwell,
  1924. # feed, strcantext, e
  1925. if drillcyc$ = 8,
  1926. [
  1927. sub_prg_call = peck1$
  1928. pcan1, pbld, n$, *sg00, *sgabsinc, pfxout, pfyout, strcantext, e$
  1929. pbld, n$, "M98", *sub_prg_call, e$
  1930. ]
  1931. else, "CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, pfcout, e$
  1932. pcom_movea
  1933.  
  1934. pcanceldc$ #Cancel canned drill cycle
  1935. result = newfs (three, zinc)
  1936. if tap_feed = one & drillcyc$ = three, result = newfs (15, feed) #Cancel tap feeds with 4/3 decimal places
  1937. z$ = initht$
  1938. !z$
  1939. if cuttype = one, prv_zia = initht$ + (rotdia$/two)
  1940. #else, prv_zia = initht #G91 Z depth from initial height
  1941. else, prv_zia = refht$ #Fanuc style - G91 Z depth from R level
  1942. pxyzcout
  1943. !zabs, !zinc
  1944. prv_gcode$ = zero
  1945. if cool_zmove = yes$ & (nextop$=1003 | (nextop$=1011 & t$<>abs(nexttool))), coolant$ = zero
  1946. pcan
  1947. if drillcyc$ <> 8, pcan1, pbld, n$, "G80", scoolant, strcantext, e$
  1948. if use_pitch & tapflg = 1, pbld, n$, "G94", e$
  1949. pcan2
  1950. tapflg = 0
  1951.  
  1952. # --------------------------------------------------------------------------
  1953. #Subprogram postblocks
  1954. #sub_trnstyp - 0=mirror, 1=rotate, 2=scale, 3=translate
  1955. #sub_trnmthd (mirror) - 0=X axis, 1=Y axis, 2=line
  1956. #sub_trnmthd (rotate) - 0=tplane, 1=tplane origin only, 2=coordinates
  1957. # --------------------------------------------------------------------------
  1958. psub_call_m$ #Call to main level, single tool
  1959. psub_call_trans
  1960.  
  1961. psub_call_mm$ #Call to main level, multiple tools
  1962. psub_call_trans
  1963.  
  1964. psub_call_trans #Translate level calls from toolchange, user
  1965. if wcstype <= one, result = mprint(shomeserror,1)
  1966. sav_absinc = absinc$
  1967. pindex
  1968. #Mirror or Rotate Coord's
  1969. if sub_trnstyp$ = zero | (sub_trnstyp$ = one & mr_rt_actv),
  1970. [
  1971. #The original pattern is not mirrored or rotated
  1972. if sub_sec_no$,
  1973. [
  1974. absinc$ = zero
  1975. if sub_trnstyp$, psub_rotate
  1976. else, psub_mirror
  1977. ]
  1978. mr_rt_actv = three
  1979. ]
  1980. else, #Translate
  1981. [
  1982. if sub_mny_t$,
  1983. [
  1984. if wcstype > one, absinc$ = zero
  1985. if lock_codes = 1 & not(index) & rot_on_x, pbld, n$, *sunlock, "(UNLOCK)", e$
  1986. pbld, n$, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfzout,
  1987. pfcout, e$
  1988. if lock_codes = 1 & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, "(LOCK)", e$
  1989. pe_inc_calc
  1990. ps_inc_calc
  1991. ]
  1992. ]
  1993. absinc$ = sav_absinc
  1994. result = nwadrs(strp, main_prg_no$)
  1995. main_prg_no$ = main_prg_no$ + sav_progno #Add sub number offset
  1996. if sav_progno = main_prg_no$, result = mprint(sprgnerror,1)
  1997. pbld, n$, "M98", *main_prg_no$, e$
  1998. prv_feed = c9k #Force feed in sub
  1999.  
  2000. psub_mirror #Mirror start code, user
  2001. #Mirror Y axis
  2002. if sub_trnmthd$, pbld, n$, *sgabsinc, strns_mir_on, *sub_trnsx$, e$
  2003. #Mirror X axis
  2004. else, pbld, n$, *sgabsinc, strns_mir_on, *sub_trnsy$, e$
  2005.  
  2006. psub_rotate #Rotate start code, user
  2007. pbld, n$, *sgcode, *sgabsinc, strns_rot_on, *sub_trnsx$, *sub_trnsy$,
  2008. [absinc$ = one], *sgabsinc, *rt_cinc, e$
  2009.  
  2010. psub_st_m$ #Header in main level
  2011. result = nwadrs(stro, main_prg_no$)
  2012. #sav_n1 = n
  2013. #n = seqno
  2014. " ", e$
  2015. *main_prg_no$, e$
  2016. spaces$ = 0
  2017. if scomm0$ <> snull, "(", *scomm0$, ")", e$
  2018. spaces$ = sav_spc
  2019. #G51/G68 requires absolute position on first move
  2020. if mr_rt_actv & absinc$ = one,
  2021. [
  2022. sav_absinc = absinc$
  2023. absinc$ = zero
  2024. prv_absinc$ = m_one
  2025. prv_xabs = m_one
  2026. prv_yabs = m_one
  2027. ]
  2028. else, pbld, n$, sgabsinc, e$
  2029.  
  2030. psub_end_m$ #End in main level
  2031. n$, "M99", e$
  2032. prv_absinc$ = -1
  2033. #n = sav_n1
  2034. #Reset update variables for subs at main level
  2035. #Mirror or Rotate cancel, output is forced
  2036. if (sub_trnstyp$ = zero & esub_sec_no$ > zero)
  2037. | (sub_trnstyp$ = one & esub_sec_no$ = esub_totl_no$-one
  2038. & sub_trnmthd$ = two),
  2039. [
  2040. subout$ = zero
  2041. no_nc_out$ = m_one
  2042. sav_absinc = absinc$
  2043. #Mirror cancel
  2044. if sub_trnstyp$ = zero,
  2045. [
  2046. absinc$ = zero
  2047. pbld, n$, *sgabsinc, strns_mir_off, *sub_trnsx$, *sub_trnsy$, e$
  2048. ]
  2049. else, #Rotate cancel
  2050. [
  2051. pbld, n$, strns_rot_off, e$
  2052. ]
  2053. absinc$ = sav_absinc
  2054. no_nc_out$ = zero
  2055. ]
  2056. end_sub_mny = sub_mny_t$
  2057.  
  2058. psub_end_mny #End in main level for many tools sub, user
  2059. #Check for coming out of xform with stage tool.
  2060. if end_sub_mny & stagetool = one,
  2061. [
  2062. *t$
  2063. end_sub_mny = zero
  2064. ]
  2065.  
  2066. psub_call_s$ #Call to sub level
  2067. result = nwadrs(strp, sub_prg_no$)
  2068. sub_prg_no$ = sub_prg_no$ + sav_progno + 1000 #Add sub number offset
  2069. if sav_progno = sub_prg_no$, result = mprint(sprgnerror,1)
  2070. pbld, n$, "M98", *sub_prg_no$, e$
  2071.  
  2072. psub_st_s$ #Header in sub level
  2073. result = nwadrs(stro, sub_prg_no$)
  2074. #sav_n2 = n
  2075. #n = seqno
  2076. " ", e$
  2077. *sub_prg_no$, e$
  2078. spaces$ = 0
  2079. if scomm0$ <> snull, "(", *scomm0$, ")", e$
  2080. spaces$ = sav_spc
  2081. pbld, n$, sgabsinc, e$
  2082.  
  2083. psub_end_s$ #End in sub level
  2084. n$, "M99", e$
  2085. prv_absinc$ = -1
  2086. #n = sav_n2
  2087.  
  2088. # --------------------------------------------------------------------------
  2089. # Canned Text
  2090. # --------------------------------------------------------------------------
  2091. pcan #Canned text - before output call
  2092. strcantext = sblank
  2093. if cant_no$ > zero,
  2094. [
  2095. if cant_pos1$ = zero, pcant_1
  2096. if cant_pos2$ = zero, pcant_2
  2097. if cant_pos3$ = zero, pcant_3
  2098. if cant_pos4$ = zero, pcant_4
  2099. if cant_pos5$ = zero, pcant_5
  2100. if cant_pos6$ = zero, pcant_6
  2101. if cant_pos7$ = zero, pcant_7
  2102. if cant_pos8$ = zero, pcant_8
  2103. if cant_pos9$ = zero, pcant_9
  2104. if cant_pos10$ = zero, pcant_10
  2105. pbld, n$, strcantext, e$
  2106. strcantext = sblank
  2107. ]
  2108.  
  2109. pcan1 #Canned text - with move
  2110. strcantext = sblank
  2111. if cant_no$ > zero,
  2112. [
  2113. if cant_pos1$ = one, pcant_1
  2114. if cant_pos2$ = one, pcant_2
  2115. if cant_pos3$ = one, pcant_3
  2116. if cant_pos4$ = one, pcant_4
  2117. if cant_pos5$ = one, pcant_5
  2118. if cant_pos6$ = one, pcant_6
  2119. if cant_pos7$ = one, pcant_7
  2120. if cant_pos8$ = one, pcant_8
  2121. if cant_pos9$ = one, pcant_9
  2122. if cant_pos10$ = one, pcant_10
  2123. ]
  2124. if cstop$, strcantext = strcantext + sm00
  2125. if cgstop$, strcantext = strcantext + sm01
  2126. #Output of strcantext occurs at the end of the output line
  2127.  
  2128. pcan2 #Canned text - after output call
  2129. strcantext = sblank
  2130. if cant_no$ > zero,
  2131. [
  2132. if cant_pos1$ = two, pcant_1
  2133. if cant_pos2$ = two, pcant_2
  2134. if cant_pos3$ = two, pcant_3
  2135. if cant_pos4$ = two, pcant_4
  2136. if cant_pos5$ = two, pcant_5
  2137. if cant_pos6$ = two, pcant_6
  2138. if cant_pos7$ = two, pcant_7
  2139. if cant_pos8$ = two, pcant_8
  2140. if cant_pos9$ = two, pcant_9
  2141. if cant_pos10$ = two, pcant_10
  2142. pbld, n$, strcantext, e$
  2143. strcantext = sblank
  2144. ]
  2145.  
  2146. pcant_1 #Canned text - output call
  2147. cantext$ = cant_val1$
  2148. pcant_out
  2149.  
  2150. pcant_2 #Canned text - output call
  2151. cantext$ = cant_val2$
  2152. pcant_out
  2153.  
  2154. pcant_3 #Canned text - output call
  2155. cantext$ = cant_val3$
  2156. pcant_out
  2157.  
  2158. pcant_4 #Canned text - output call
  2159. cantext$ = cant_val4$
  2160. pcant_out
  2161.  
  2162. pcant_5 #Canned text - output call
  2163. cantext$ = cant_val5$
  2164. pcant_out
  2165.  
  2166. pcant_6 #Canned text - output call
  2167. cantext$ = cant_val6$
  2168. pcant_out
  2169.  
  2170. pcant_7 #Canned text - output call
  2171. cantext$ = cant_val7$
  2172. pcant_out
  2173.  
  2174. pcant_8 #Canned text - output call
  2175. cantext$ = cant_val8$
  2176. pcant_out
  2177.  
  2178. pcant_9 #Canned text - output call
  2179. cantext$ = cant_val9$
  2180. pcant_out
  2181.  
  2182. pcant_10 #Canned text - output call
  2183. cantext$ = cant_val10$
  2184. pcant_out
  2185.  
  2186. pcant_out #Canned text - build the string for output
  2187. #Assign string select type outputs
  2188. if cantext$ = three, bld = one
  2189. if cantext$ = four, bld = zero
  2190. #Build the cantext string
  2191. if cantext$ = one, strcantext = strcantext + sm00
  2192. if cantext$ = two, strcantext = strcantext + sm01
  2193. if cantext$ > four,
  2194. [
  2195. strtextno = no2str(cantext$)
  2196. strcantext = strcantext + strm + strtextno
  2197. ]
  2198.  
  2199. # --------------------------------------------------------------------------
  2200. # Position calculations, generally these do not need to be modified
  2201. # --------------------------------------------------------------------------
  2202. pmiscint$ #Capture the top level absinc for subprograms
  2203. if sub_level$ <= zero, absinc$ = mi2$
  2204. #Disable cutpos2 if not 4 axis, saves time
  2205. if rot_on_x = zero, cutpos2$ = m_one
  2206.  
  2207. pusecannedyes # Use canned drilling cycles
  2208. usecandrill$ = yes$ # Use canned cycle for drill
  2209. usecanpeck$ = yes$ # Use canned cycle for Peck
  2210. usecanchip$ = yes$ # Use canned cycle for Chip Break
  2211. usecantap$ = yes$ # Use canned cycle for Tap
  2212. usecanbore1$ = yes$ # Use canned cycle for Bore1
  2213. usecanbore2$ = yes$ # Use canned cycle for Bore2
  2214. usecanmisc1$ = yes$ # Use canned cycle for Misc1
  2215. usecanmisc2$ = yes$ # Use canned cycle for Misc2
  2216.  
  2217. pusecannedno # Use canned drilling cycles
  2218. usecandrill$ = no$ # Use canned cycle for drill
  2219. usecanpeck$ = no$ # Use canned cycle for Peck
  2220. usecanchip$ = no$ # Use canned cycle for Chip Break
  2221. usecantap$ = no$ # Use canned cycle for Tap
  2222. usecanbore1$ = no$ # Use canned cycle for Bore1
  2223. usecanbore2$ = no$ # Use canned cycle for Bore2
  2224. usecanmisc1$ = no$ # Use canned cycle for Misc1
  2225. usecanmisc2$ = no$ # Use canned cycle for Misc2
  2226.  
  2227. pmotion_su #Motion Setup (Set brklinestype & linarc)
  2228. brklinestype$ = zero
  2229. linarc$ = zero
  2230. if rot_on_x,
  2231. [
  2232. if cuttype = one, linarc$ = one #Axis subs
  2233. if cuttype = two, #Polar
  2234. [
  2235. brklinestype$ = rotary_axis$ + three
  2236. linarc$ = one
  2237. ]
  2238. ]
  2239.  
  2240. pcuttype #Determine the cut type
  2241. #cuttype (0 = Tool Plane, 1 = Axis Subs, 2 = Polar, 3 = 4/5 axis)
  2242. cuttype = rotary_type$
  2243. if cuttype = three, cuttype = zero
  2244. if mill5$,
  2245. [
  2246. if rot_on_x = zero, result = mprint(saxisoff,1)
  2247. cuttype = three
  2248. ]
  2249. if rotary_axis$,
  2250. [
  2251. if rotary_axis$ <> rot_on_x, result = mprint(saxiswarn,1)
  2252. rot_on_x = rotary_axis$
  2253. ]
  2254. #Check for Tool Origin in Polar Milling
  2255. if cuttype = two & (tox$ | toy$ | toz$), result = mprint(stlorgerr,1)
  2256. #Transform Rotate, set mr_rt_actv if user selected 'coordinates'
  2257. if sub_trnstyp$ = one & sub_trnmthd$ = two,
  2258. [
  2259. #Calculate the rotation incremental angle for G68
  2260. rt_csav = atan2(sub_m2$, sub_m1$)
  2261. rt_cinc = prv_rt_csav - rt_csav
  2262. while rt_cinc > 180, rt_cinc = rt_cinc - 360
  2263. while rt_cinc < -180, rt_cinc = rt_cinc + 360
  2264. if rot_ccw_pos = one, rt_cinc = -rt_cinc
  2265. !rt_csav
  2266. if sub_sec_no$, mr_rt_actv = two
  2267. else, mr_rt_actv = one
  2268. ]
  2269. else, mr_rt_actv = zero
  2270. pfcalc_u_min
  2271. pmotion_su
  2272.  
  2273. pxyzcout #Map coordinates
  2274. if rot_on_x,
  2275. [
  2276. if cuttype = zero, pxyzcout0 #Toolplane Positioning
  2277. if cuttype = one, pxyzcout1 #Axis Substitution
  2278. if cuttype = two, pxyzcout2 #Polar Conversion
  2279. if cuttype = three, pxyzcout3 #Simulatneous 4 axis (Multi-axis)
  2280. if rot_ccw_pos = one, csav = -csav
  2281. if mr_rt_actv <> two,
  2282. [
  2283. pcoutrev
  2284. if index, pindxcalc
  2285. pfcalc
  2286. ]
  2287. else, feed = fr_pos$
  2288. ]
  2289. else,
  2290. [
  2291. xabs = vequ (x$)
  2292. feed = fr_pos$
  2293. ]
  2294.  
  2295. pxyzcout0 #Toolplane Positioning
  2296. xabs = vequ (x$)
  2297. if cuttype = 2 & rot_on_x = two & vmc, c$ = atan2(vtoolx$,-vtooly$)
  2298. if rot_on_x = two, csav = -c$
  2299. else, csav = c$
  2300.  
  2301. pxyzcout1 #Axis substitution
  2302. if rot_on_x = one, #X axis substitution
  2303. [
  2304. xabs = x$
  2305. yabs = zero
  2306. zabs = z$ + (rotdia$ / two)
  2307. csav = y$ * (360 / (pi$ * rotdia$))
  2308. ]
  2309. else, #Y axis substitution
  2310. [
  2311. xabs = zero
  2312. yabs = y$
  2313. zabs = z$ + (rotdia$ / two)
  2314. csav = -x$ * (360 / (pi$ * rotdia$))
  2315. ]
  2316. if c$ <> 0,
  2317. [
  2318. if rot_on_x = two, csav = -c$
  2319. else, csav = c$
  2320. ]
  2321.  
  2322. pxyzcout2 #polar interpolation
  2323. #Drill polar is toolplane drilling toward center
  2324. #if not a coincident axis
  2325. #Also, Capture initial index position for Polar Milling
  2326. if (opcode$ = three & rot_on_x <> three), pxyzcout0
  2327. else,
  2328. [
  2329. if rot_on_x = one, #X axis rotation
  2330. [
  2331. csav = atan2(y$, z$) #Z+ zero
  2332. axisx$ = vequ(aaxisx)
  2333. xabs = rotp(csav, x$)
  2334. ]
  2335. if rot_on_x = two, #Y axis rotation
  2336. [
  2337. csav = atan2(-x$, z$) #Z+ zero
  2338. axisx$ = vequ(baxisx)
  2339. xabs = rotp(csav, x$)
  2340. ]
  2341. if rot_on_x = three, #Z axis rotation
  2342. [
  2343. csav = atan2(-y$, x$) #X+ zero
  2344. #csav = -atan2(y, -x) #X- zero
  2345. #csav = -atan2(x, y) #Y+ zero
  2346. #csav = -atan2(-x, -y) #Y- zero
  2347. axisx$ = vequ(caxisx)
  2348. xabs = rotp(csav, x$)
  2349. ]
  2350. csav = csav + c$
  2351. ]
  2352.  
  2353. pxyzcout3 #Multisurf rotary axis motion
  2354. #Use Top toolplane for vmc = 1, Front for vmc = 0
  2355. if rot_on_x = one, #Multisurf Rotary about X
  2356. [
  2357. csav = atan2 (vtooly$, vtoolz$)
  2358. axisx$ = vequ (aaxisx)
  2359. ]
  2360. if rot_on_x = two, #Multisurf Rotary about Y
  2361. [
  2362. csav = atan2 (-vtoolx$, vtoolz$)
  2363. axisx$ = vequ (baxisx)
  2364. ]
  2365. xabs = rotp (csav, x$)
  2366. u$ = rotp (csav, u$)
  2367. csav = csav + c$
  2368.  
  2369. pcoutrev #Rotary axis revolution calculation (Modify for wind-up)
  2370. cdelta = csav - prv_csav
  2371. while abs(cdelta) > ctol, #If motion exceeds ctol, add wind-up
  2372. [
  2373. if cdelta > zero,
  2374. [
  2375. rev = rev - one
  2376. cdelta = cdelta - 360
  2377. ]
  2378. else,
  2379. [
  2380. rev = rev + one
  2381. cdelta = cdelta + 360
  2382. ]
  2383. ]
  2384. if cuttype <> one, cabs = rev * 360 + csav
  2385. else, cabs = sav_rev * 360 + csav
  2386.  
  2387. if (cuttype = zero | opcode$ = 3 | (gcode$ = 0 & cuttype <> one)) & one_rev = one,
  2388. [
  2389. while fmtrnd(cabs) >= 360,
  2390. [
  2391. cabs = cabs - 360
  2392. rev = rev - 1
  2393. ]
  2394. while fmtrnd(cabs) < 0,
  2395. [
  2396. cabs = cabs + 360
  2397. rev = rev + 1
  2398. ]
  2399. #while fmtrnd(cabs) < -360,
  2400. # [
  2401. # cabs = cabs + 720
  2402. # rev = rev + 2
  2403. # ]
  2404. if abs(cdelta) >= 0.0005, prv_cabs = c9k
  2405. ]
  2406. !csav
  2407.  
  2408. pindxcalc #Index move calculations, direction is shortest
  2409. #Check if in tolerance
  2410. cdelta = frac(abs(csav)/ctable)
  2411. if cdelta > ixtol & cdelta < 1-ixtol,
  2412. result = mprint(sindxerror,1)
  2413. cdelta = prvcabs - cabs
  2414. #Phase shift delta 10 revolutions, check odd/even
  2415. if frac(int((cdelta + 3600)/180)/two), indx_mc = one
  2416. else, indx_mc = zero
  2417. #Set range 0-360
  2418. indx_out = csav
  2419. while indx_out < 0, indx_out = indx_out + 360
  2420. while indx_out > 360, indx_out = indx_out - 360
  2421.  
  2422. #Feedrate calculations
  2423. pfcalc #Feedrate calculations, gcode 0 does not evaluate
  2424. if gcode$ <> zero,
  2425. [
  2426. if not(use_frinv) & (abs(fmtrnd(cabs)-prvcabs) <= 0.001 | index | not(rot_feed) | opcode$ = 3), pfcalc_u_min
  2427. else,
  2428. [
  2429. #if cuttype = one & (cutpos2 <= one), #Proposed change
  2430. if cuttype = one & (cutpos2$ <= one | cutpos2$ = four & (opcode$ < 5 & opcode$ > 12)), pfcalc_u_min
  2431. else, pfclc_deg_inv
  2432. ]
  2433. if ipr_type <> prv_ipr_type, prv_feed = c9k
  2434. ]
  2435.  
  2436. pfcalc_u_min #Feedrate unit/min
  2437. ipr_type = zero
  2438. feed = fr_pos$
  2439. if feed > maxfeedpm, feed = maxfeedpm
  2440. prvfrdeg = feed
  2441.  
  2442. pfclc_deg_inv #Feedrate deg/min
  2443. circum = zabs * two * pi$
  2444. if cuttype = two & rot_on_x = three, circum = sqrt(xabs^2 + yabs^2) * two * pi$
  2445. if circum = zero, circum = c9k #Don't allow Zero
  2446. ldelta = sqrt((xabs-prv_xabs)^2+(yabs-prv_yabs)^2+(zabs-prv_zabs)^2)
  2447. cdelta = ((abs(cabs - prvcabs))/360)*circum
  2448. if ldelta = zero, cldelta = cdelta
  2449. else, cldelta = sqrt(cdelta^two + ldelta^two)
  2450. if cldelta = zero, cldelta = c9k
  2451. if use_frinv,
  2452. [
  2453. #Feedrate inverse calculation
  2454. ipr_type = two
  2455. result = force(feed, feed) #Always force feed
  2456. if cuttype = three, cldelta = sqrt((x$-prv_x$)^2+(y$-prv_y$)^2+(z$-prv_z$)^2)
  2457. frinv = fr_pos$/cldelta # 1/min
  2458. #frinv = fr_pos/(60*cldelta) # 1/sec
  2459. if rot_feed & opcode$ <> 3 & opcode$ <> 16,
  2460. [
  2461. if frinv > maxfrinv, frinv = maxfrinv
  2462. feed = frinv
  2463. ]
  2464. ]
  2465. else,
  2466. [
  2467. #Feedrate deg/min control and calculation
  2468. ipr_type = zero #Change to ipr_type = one to force new DPM
  2469. #frdeg = abs(cdelta/cldelta) * abs(fr_pos * (360/circum))
  2470. frdeg = fr_pos$ * abs((cabs - prvcabs)/cldelta)
  2471. if abs(frdeg - prvfrdeg) > frdegstp | ipr_type <> prv_ipr_type,
  2472. [
  2473. #Control output of frdeg
  2474. if rot_feed & opcode$ <> 3 & opcode$ <> 16,
  2475. [
  2476. prvfrdeg = frdeg
  2477. feed = frdeg
  2478. ]
  2479. ]
  2480. if frdeg < fr_pos$ & rot_feed, feed = fr_pos$
  2481. if frdeg > maxfrdeg & rot_feed, feed = maxfrdeg
  2482. ]
  2483.  
  2484. #Incremental calculations
  2485. ps_inc_calc #Incremental calculations, start
  2486. xia = fmtrnd(xabs)
  2487. yia = fmtrnd(yabs)
  2488. zia = fmtrnd(zabs)
  2489. xinc = vsub (xia, prv_xia)
  2490. ps_cinc_calc
  2491.  
  2492. ps_cinc_calc #Incremental calculations, start rotary
  2493. cia = fmtrnd(cabs)
  2494. cinc = cia - prv_cia
  2495.  
  2496. pe_inc_calc #Incremental calculations, end
  2497. prvcabs = fmtrnd(cabs) #Avoid updating until called explicitly
  2498. !xia, !yia, !zia, !cia
  2499. !x$, !y$, !z$, !cc_pos$, !cutpos2$
  2500.  
  2501. # --------------------------------------------------------------------------
  2502. # Tooltable Output
  2503. # --------------------------------------------------------------------------
  2504. pwrtt$ # Write tool table, scans entire file, null tools are negative
  2505. if rotaxis$ > 0 | rotary_type$ > 0 | mill5$ <> 0,
  2506. [
  2507. rot_on_x = sav_rot_on_x
  2508. output_z = no$
  2509. ]
  2510. #if vmc = 0 & tlplnno <> 2, rot_on_x = sav_rot_on_x
  2511. #if vmc = 1 & tlplnno > 1, rot_on_x = sav_rot_on_x
  2512. if tlplnno$ > 1, rot_on_x = sav_rot_on_x
  2513. tlplnno$ = wbuf(3,wc3) #Buffers out tool plane values
  2514. t$ = wbuf(4,wc4) #Buffers out tool number values
  2515. if tool_table = 1, ptooltable,e$
  2516. if tool_table = 2, ppredtool,e$
  2517. if tool_table = 3, pmetatool,e$
  2518. if t$ >= zero, tcnt = tcnt + one
  2519. ptravel
  2520. pwritbuf5
  2521.  
  2522. ptooltable # Write tool table, scans entire file, null tools are negative
  2523. tnote = t$
  2524. toffnote = tloffno$
  2525. tlngnote = tlngno$
  2526. spaces$=0
  2527. if t$ >= zero,
  2528. [
  2529. if tcr$>0, "(",*t$, " - " , *tldia$, " " , ppredtool, ")"
  2530.  
  2531. if tcr$=0, "(",*t$, " - " , *tldia$, " " , ppredtool, ")"
  2532.  
  2533. ]
  2534. #if t >= zero,
  2535. # [
  2536. # "(",*t, " - " , *tldia, " " , ppredtool, ")"
  2537.  
  2538. # ]
  2539. #if t >= zero,
  2540. # [
  2541. # if tcr>0, "(",*t, " - " , *tldia, " " , ppredtool, ")"
  2542.  
  2543. # if tcr=0, "(",*t, " - " , *tldia, " " , ppredtool, ")"
  2544.  
  2545. # ]
  2546. spaces$=sav_spc
  2547.  
  2548. punit # Tool unit
  2549. if met_tool$, "mm"
  2550. else, 34
  2551.  
  2552. ptravel # Tool travel limit calculation
  2553. if x_min$ < x_tmin, x_tmin = x_min$
  2554. if x_max$ > x_tmax, x_tmax = x_max$
  2555. if y_min$ < y_tmin, y_tmin = y_min$
  2556. if y_max$ > y_tmax, y_tmax = y_max$
  2557. if z_min$ < z_tmin, z_tmin = z_min$
  2558. if z_max$ > z_tmax, z_tmax = z_max$
  2559.  
  2560. ppredtool # Write tool setup info for Predator Virtual CNC
  2561. #if tool_typ = 1, styp1 # CENTER DRILL 1 - NTG/S4
  2562. #if tool_typ = 2, styp2 # SPOT DRILL 2 - S4
  2563. #if tool_typ = 3, styp3 # DRILL 3 - S4
  2564. #if tool_typ = 4, styp4 # TAP-RH 4 - S4 - MAX 179 ANGLE
  2565. #if tool_typ = 5, styp5 # TAP-LH 5 - S4 - MAX 179 ANGLE
  2566. #if tool_typ = 6, styp6 # REAMER 6 - S3/S1/S2
  2567. #if tool_typ = 7, styp7 # BORING BAR 7 - S3/S1/S2
  2568. #if tool_typ = 8, styp8 # COUNTER BORE 8 - NTG
  2569. #if tool_typ = 9, styp9 # COUNTER SINK 9 - NTG/S4
  2570. #if tool_typ = 10, styp10 # END MILL FLAT 10 - S1
  2571. #if tool_typ = 11, styp11 # END MILL SPHERE 11 - S2
  2572. #if tool_typ = 12, styp12 # CHAMFER MILL 12 - S7/NTG
  2573. #if tool_typ = 13, styp13 # FACE MILL 13 - S7/S9/NTG
  2574. #if tool_typ = 14, styp14 # SLOT MILL 14 - NTG/S1
  2575. #if tool_typ = 15, styp15 # CORNER RAD MILL 15 - S5/FLAT
  2576. #if tool_typ = 16, styp16 # DOVETAIL MILL 16 - DOVETAIL/NTG
  2577. #if tool_typ = 17, styp17 # TAPER MILL 17 - S7/S9/S10
  2578. #if tool_typ = 18, styp18 # LOLLIPOP MILL 18 - S6
  2579. #if tool_typ = 19, styp19 # END MILL BULL 19 - S3
  2580.  
  2581. tcr_pred = tcr$
  2582. tldia_pred = tldia$
  2583. tip_angle_ch = tip_angle*2
  2584. spaces$=0
  2585.  
  2586. if t$ >= zero,
  2587. [
  2588. # CENTER DRILL
  2589. if tool_typ$ = 1, "CENTER DRILL"
  2590. # SPOT DRILL
  2591. if tool_typ$ = 2, "SPOT DRILL"
  2592. # DRILL
  2593. if tool_typ$ = 3, "DRILL"
  2594. # TAP-RH
  2595. if tool_typ$ = 4,
  2596. [
  2597. if tip_angle <= 179, "TAP "
  2598. else, "TAP"
  2599. ]
  2600. # TAP-LH
  2601. if tool_typ$ = 5,
  2602. [
  2603. if tip_angle <= 179, "TAP"
  2604. else, "TAP"
  2605. ]
  2606. # REAMER
  2607. if tool_typ$ = 6,
  2608. [
  2609. if tcr$ = 0, "REAMER"
  2610. if tcr$ = tlrad$, "REAMER"
  2611. if tcr$ > 0 & tcr$ < tlrad$, "REAMER"
  2612.  
  2613. ]
  2614. # BORING BAR
  2615. if tool_typ$ = 7,
  2616. [
  2617. if tcr$ = 0, "BORING BAR"
  2618. if tcr$ = tlrad$, "BORING BAR"
  2619. if tcr$ > 0 & tcr$ < tlrad$, "BORING BAR"
  2620. ]
  2621. # COUNTER BORE
  2622. if tool_typ$ = 8,
  2623. [
  2624. if tcr$ = 0, "COUNTER BORE"
  2625. if tcr$ = tlrad$, "COUNTER BORE"
  2626. if tcr$ > 0 & tcr$ < tlrad$, "COUNTER BORE"
  2627. ]
  2628. # COUNTER SINK
  2629. if tool_typ$ = 9, "COUNTER SINK"
  2630. # END MILL FLAT
  2631. if tool_typ$ = 10, "END MILL"
  2632. # END MILL SPHERE
  2633. if tool_typ$ = 11, "BALL END MILL"
  2634. # CHAMFER MILL
  2635. if tool_typ$ = 12, "N/C DRILL"
  2636. # FACE MILL
  2637. if tool_typ$ = 13, "FACE MILL"
  2638. # SLOT MILL
  2639. if tool_typ$ = 14, "SLOT MILL"
  2640. # CORNER RAD MILL
  2641. if tool_typ$ = 15,
  2642. [
  2643. if tcr$ = 0, *tcr_pred, " ", "CORNER RAD END MILL"
  2644. else, *tcr_pred, " ", "CORNER RAD END MILL"
  2645.  
  2646.  
  2647. ]
  2648. # DOVETAIL MILL
  2649. if tool_typ$ = 16, "DOVETAIL MILL"
  2650. # TAPER MILL
  2651. if tool_typ$ = 17,
  2652. [
  2653. if tcr$ = 0, "TAPER MILL"
  2654. if tcr$ = tlrad$, "TAPER MILL"
  2655. if tcr$ > 0 & tcr$ < tlrad$, "TAPER MILL"
  2656. ]
  2657. # LOLLIPOP MILL
  2658. if tool_typ$ = 18, "LOLLIPOP MILL"
  2659. # END MILL BULL
  2660. if tool_typ$ = 19, "END MILL BULL"
  2661. ]
  2662. spaces$=sav_spc
  2663.  
  2664. pmetatool # Write tool setup info for MetaCut View
  2665. tcr_meta = tcr$
  2666. if tool_typ$ = 13 | tool_typ$ = 17, tldia_meta = tldia$ + (2 *(flute_len * tan(tip_angle)))
  2667. else, tldia_meta = tldia$
  2668. if cctotip$ = 0, tipcomp = 1
  2669. else, tipcomp = 0
  2670. if tool_typ$ = 10 | opcode$ = 3, tipcomp = 0
  2671. if tool_typ$ = 12, td_meta = tip_dia
  2672. else, td_meta = 0
  2673. if tool_typ$ = 13 | tool_typ$ = 17, td_meta = tldia$
  2674. flute_meta = flute_len
  2675. oa_meta = oa_len
  2676. ta_meta = tip_angle
  2677. cd_meta = hldr_dia
  2678. cl_meta = hldr_len
  2679. sd_meta = cd_meta
  2680.  
  2681. #(NWDTOOL NAME"1/2 CHAMFER MILL" T1 D.5 R0. F2. L3. A45. TD.06 CD2. CL1. SD2. C0)
  2682. # N = "Tool name"
  2683. # T = Tool No.
  2684. # D = Tool Dia.
  2685. # R = Corner Radius
  2686. # F = Flute Length
  2687. # L = Tool over all length
  2688. # A = Tip angle or Taper angle
  2689. # TD = Tip Dia.
  2690. # CD = Colllet/Holder Dia.
  2691. # CL = Collet/Holder Height
  2692. # SD = Spindle Dia. (set equal to Collet Diameter)
  2693. # C = tip or center 0 = tip 1 = center
  2694.  
  2695. spaces$=0
  2696. if t$ >= zero, "(NWDTOOL N", 34, pmetacomm, 34, " ", *t$, " ", *tldia_meta, " ",
  2697. [if tcr_meta > 0, *tcr_meta, " "], *flute_meta, " ", *oa_meta, " ",
  2698. [if ta_meta<>180, *ta_meta, " "], [if td_meta > 0, *td_meta, " "],
  2699. *cd_meta, " ", *cl_meta, " ", *sd_meta, " ", *tipcomp, ")"
  2700. spaces$=sav_spc
  2701.  
  2702. # --------------------------------------------------------------------------
  2703. # Buffer 5 Read / Write Routines
  2704. # --------------------------------------------------------------------------
  2705. pwritbuf5 # Write Buffer 1
  2706. b5_gcode = gcode$
  2707. b5_zmin = z_min$
  2708. b5_zmax = z_max$
  2709. b5_gcode = wbuf(5, wc5)
  2710.  
  2711. preadbuf5 # Read Buffer 1
  2712. size5 = rbuf(5,0)
  2713. b5_gcode = 1000
  2714. min_depth = 99999
  2715. max_depth = -99999
  2716. while rc5 <= size5 & b5_gcode = 1000,
  2717. [
  2718. if rc5 <= size5, b5_gcode = rbuf(5,rc5)
  2719. if b5_zmin < min_depth, min_depth = b5_zmin
  2720. if b5_zmax > max_depth, max_depth = b5_zmax
  2721. ]
  2722.  
  2723. # --------------------------------------------------------------------------
  2724. # Numbered questions for Mastercam
  2725. # --------------------------------------------------------------------------
  2726. 38. Rapid feedrate? 300.0
  2727. #76. 관련된 CFG 파일 이름은? T
  2728. #400. 관련된 CFG 파일 이름은? T
  2729. 1538. Rapid feedrate (metric)? 2000.0
  2730. #76. Configuration file name?
  2731. 80. Communications port number for receive and transmit (1 or 2) ? 2
  2732. 81. Data rate (110,150,300,600,1200,2400,4800,9600,14400,19200,38400)? 9600
  2733. 82. Parity (E/O/N)? E
  2734. 83. Data bits (7 or 8)? 7
  2735. 84. Stop bits (1 or 2)? 2
  2736. 85. Strip line feeds? N
  2737. 86. Delay after end of line (seconds)? 0
  2738. 87. Ascii, Eia, or Binary (A/E/B)? A
  2739. 88. Echo keyboard to screen in terminal emulation? n
  2740. 89. Strip carriage returns? N
  2741. 90. Drive and subdirectory for NC files?
  2742. 91. Name of executable post processor? MP
  2743. 92. Name of reverse post processor? RP
  2744. 93. Reverse post PST file name? RPFAN
  2745. 100. Number of places BEFORE the decimal point for sequence numbers? 0
  2746. 101. Number of places AFTER the decimal point for sequence numbers? 0
  2747. 103. Maximum spindle speed? 10000
  2748. 107. Average time for tool change (seconds)? 2.0
  2749. 159. Show first and last position as fully compensated in simulation? n
  2750. 161. Enable Home Position button? y
  2751. 162. Enable Reference Point button? y
  2752. 163. Enable Misc. Values button? y
  2753. 164. Enable Rotary Axis button? y
  2754. 165. Enable Tool Plane button? y
  2755. 166. Enable Construction Plane button? y
  2756. 167. Enable Tool Display button? y
  2757. 168. Check tplane during automatic work origin creation? y
  2758.  
  2759. # --------------------------------------------------------------------------
  2760. # Default Miscellaneous Real Values
  2761. # --------------------------------------------------------------------------
  2762. 201. Default miscellaneous real variable 1 (mr1)? 0.0
  2763. 202. Default miscellaneous real variable 2 (mr2)? 0.0
  2764. 203. Default miscellaneous real variable 3 (mr3)? 0.0
  2765. 204. Default miscellaneous real variable 4 (mr4)? 0.0
  2766. 205. Default miscellaneous real variable 5 (mr5)? 0.0
  2767. 206. Default miscellaneous real variable 6 (mr6)? 0.0
  2768. 207. Default miscellaneous real variable 7 (mr7)? 0.0
  2769. 208. Default miscellaneous real variable 8 (mr8)? 0.0
  2770. 209. Default miscellaneous real variable 9 (mr9)? 0.0
  2771. 210. Default miscellaneous real variable 10 (mr10)? 0.0
  2772.  
  2773. # --------------------------------------------------------------------------
  2774. # Default Miscellaneous Real Values (METRIC)
  2775. # --------------------------------------------------------------------------
  2776. 1601. Default miscellaneous real variable 1 (mr1) (metric)? 0.0
  2777. 1602. Default miscellaneous real variable 2 (mr2) (metric)? 0.0
  2778. 1603. Default miscellaneous real variable 3 (mr3) (metric)? 0.0
  2779. 1604. Default miscellaneous real variable 4 (mr4) (metric)? 0.0
  2780. 1605. Default miscellaneous real variable 5 (mr5) (metric)? 0.0
  2781. 1606. Default miscellaneous real variable 6 (mr6) (metric)? 0.0
  2782. 1607. Default miscellaneous real variable 7 (mr7) (metric)? 0.0
  2783. 1608. Default miscellaneous real variable 8 (mr8) (metric)? 0.0
  2784. 1609. Default miscellaneous real variable 9 (mr9) (metric)? 0.0
  2785. 1610. Default miscellaneous real variable 10 (mr10) (metric)? 0.0
  2786.  
  2787. # --------------------------------------------------------------------------
  2788. # Enable/Disable Miscellaneous Real Variable switches
  2789. # --------------------------------------------------------------------------
  2790. 1611. Enable miscellaneous real variable 1? y
  2791. 1612. Enable miscellaneous real variable 2? y
  2792. 1613. Enable miscellaneous real variable 3? y
  2793. 1614. Enable miscellaneous real variable 4? y
  2794. 1615. Enable miscellaneous real variable 5? y
  2795. 1616. Enable miscellaneous real variable 6? y
  2796. 1617. Enable miscellaneous real variable 7? y
  2797. 1618. Enable miscellaneous real variable 8? y
  2798. 1619. Enable miscellaneous real variable 9? y
  2799. 1620. Enable miscellaneous real variable 10? y
  2800.  
  2801. # --------------------------------------------------------------------------
  2802. # Default Miscellaneous Integer Values
  2803. # --------------------------------------------------------------------------
  2804. 301. Miscellaneous integer variable 1 (mi1)? 0
  2805. 302. Absolute or Incremental [0=ABS,1=INC] (mi2)? 0
  2806. 303. Miscellaneous integer variable 3 (mi3)? 0
  2807. 304. Miscellaneous integer variable 4 (mi4)? 0
  2808. 305. Miscellaneous integer variable 5 (mi5)? 0
  2809. 306. Miscellaneous integer variable 6 (mi6)? 0
  2810. 307. Miscellaneous integer variable 7 (mi7)? 0
  2811. 308. Miscellaneous integer variable 8 (mi8)? 0
  2812. 309. Lock on First WCS [0=No,1=Yes] (mi9)? 0
  2813. 310. M00 before operation [0=No,1=Yes] (mi10)? 0
  2814.  
  2815. # --------------------------------------------------------------------------
  2816. # Enable/Disable Miscellaneous Integer Variable switches
  2817. # --------------------------------------------------------------------------
  2818. 1621. Enable miscellaneous integer variable 1? y
  2819. 1622. Enable miscellaneous integer variable 2? y
  2820. 1623. Enable miscellaneous integer variable 3? y
  2821. 1624. Enable miscellaneous integer variable 4? y
  2822. 1625. Enable miscellaneous integer variable 5? y
  2823. 1626. Enable miscellaneous integer variable 6? y
  2824. 1627. Enable miscellaneous integer variable 7? y
  2825. 1628. Enable miscellaneous integer variable 8? y
  2826. 1629. Enable miscellaneous integer variable 9? y
  2827. 1630. Enable miscellaneous integer variable 10? y
  2828.  
  2829. # --------------------------------------------------------------------------
  2830. # Configuration File association parameters (default is "y")
  2831. # --------------------------------------------------------------------------
  2832. #400. Name of associated cfg file?
  2833. 401. Read SYSTEM COLORS section? y
  2834. 402. Read ALLOCATIONS section? y
  2835. 403. Read TOLERANCES section? y
  2836. 404. Read DATA PATHS section? y
  2837. 405. Read COMMUNICATIONS section? y
  2838. 406. Read DRAFT SETTINGS section? y
  2839. 407. Read MISCELLANEOUS section? y
  2840. 408. Read NC SETTINGS section? y
  2841. 409. Read DIALOG SCRIPTS section? y
  2842. 410. Read DESIGN SETTINGS section? y
  2843. 411. Read PLOTTER SETTINGS section? y
  2844. 412. Read ALT-KEY ASSIGNMENTS section? y
  2845. 413. Read CAD section? y
  2846. 414. Read START/EXIT section? y
  2847. 415. Read SCREEN section? y
  2848. 416. Read FILE NAMES section? y
  2849.  
  2850. 1500. Chook to execute from 'Misc. values' button?
  2851. 1501. Insert parameter information in the ascii NCI? n
  2852. 1502. Write operation information to binary file (.ops)? y
  2853. 1503. Write transform operations (0=transform ops, 1=source ops, 2=both)? 1
  2854.  
  2855. 1520. Display a warning when cutter compensation in control simulation finds an error? n
  2856. 1521. Number of controller look-ahead blocks for CDC in control? 2
  2857.  
  2858. 1530. Ignore work offset numbers when processing subprograms? y
  2859. 1531. Ignore contour flags when processing subprograms? y
  2860.  
  2861. # Do NOT manually change the answer for Q.1999 !
  2862. 1999. Product major version number that post supports? 9
  2863.  
  2864. 3001. Machine acceleration? 2
  2865. 3002. timing size? .1
  2866.  
  2867.  
  2868.  
  2869. [CTRL_TEXT_END]
  2870.  
Add Comment
Please, Sign In to add comment