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