Use Saved Process: Difference between revisions

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