Use Saved Process

From Macros Wiki
Jump to: navigation, search
!    create geometry and machine it using a saved process
a1$ = "This macro will create a shape and rotate it."
a2$ = "Then it will use a saved process to machine the part."
a3$ = "It will set the tool side and the start and end markers"
message "%a1$\n%a2$\n\n%a3$"
dialog "GeoSavedProcess.dlg"
!    a1 = incline angle
!    a2 = included angle
!    ww = width
!    ll = length
!    xs = start point
!    ys = start point
degrees  !    switch all trig functions to degrees
d2 = (ll * tan(90-a2))
w2= (ww-d2-d2)  !    length of short end of shape
new_part "Example.vnc"
set_part_data mdd_name, "VMill3a"  !    3 axis vertical mill
set_part_data units, 1  !    inches
!    set the stock size
!    ------------------
set_part_data stock_x1, xs-ll
set_part_data stock_y1, ys-ll
set_part_data stock_z1, 0
set_part_data stock_x2, xs+ll
set_part_data stock_y2, ys+ll
set_part_data stock_z2, 1
set_view top
zoom_view 0
if messages=1 then message "Create contour, without rotation"
contour [
start xs, ys
line xs+ll, ys+d2
line xs+ll, ys+d2+w2
line xs, ys+ww
line xs, ys
iref = ContourRef
if messages=1 then message "select contour"
select_shape iref  !    select the shape
if messages=1 then message "Rotate to inclination angle and Shrink Wrap"
rotate_geo xs,ys,a1
if messages=1 then message "Set markers, load process and create ops"
set_markers 1, 1, 0.5, 1, 0.5
load_process "GeoSavedProcess.prc"
calc_process !    do it
clear_select !    deselect all
if messages=1 then message "Select ISO view"
set_view iso
if messages=1 then message "Zoom out"
zoom_view 0  !    unzoom
zoom_view 0.8  !    zoom out
if messages=1 then message "Set the stock size"
get_part_data stock_x1, x1
get_part_data stock_y1, y1
get_part_data stock_x2, x2
get_part_data stock_y2, y2
if messages=1 then message "Current Stock\nXmin=%x1 Ymin=%y1\nXmax=%x2 Ymax=%y2"
xx = x2 - x1
yy = y2 - y1
xc = (x1 + x2) / 2
yc = (y1 + y2) / 2
!    add 10% to the stock in X and Y
x1 = xc - (xx * 0.6)
x2 = xc + (xx * 0.6)
y1 = yc - (yy * 0.6)
y2 = yc + (yy * 0.6)
!    set stock Z according to process 1 Z data
get_proc_data 1, surf_z, z2
get_proc_data 1, tip_z, z1
if messages=0 then goto set_part_data
message "Check the Z values from process 1"
debug z1
debug z2
message "Change the stock size"
set_part_data stock_x1, x1
set_part_data stock_x2, x2
set_part_data stock_y1, y1
set_part_data stock_y2, y2
set_part_data stock_z1, z1-0.1
set_part_data stock_z2, z2-0.1
if messages=1 then message "Finished"