briankorsedal
08-21-2008, 07:41 PM
Hi,
I just started programming in spb files. Here is a file I want to run. It doesn't do anything in the simulator. Is it a valid file? Any things you can see that I am doing wrong?
'this is a file containing subroutines for producing three
'dimensional designs using interlocking faces cut out of
'high quality plywood
'
'the command structure should be
'start point x, start point y, end point x, end point y, angle of connection, type of edge, type of material, cutter
&spx = 10
&spy = 10
&epx = 10
&epy = 20
&angle = 90
&type = connect
&material = oak_ply_12_mm
&cutter = unknown
&tooth_count = 7
&cut_count = 3
gosub m2_start
bill.young
08-21-2008, 08:53 PM
Hi Brian,
Great start. I see a few syntax errors that could cause problems, but it's a great use of system variables and position tests. Here are some things to try (though I'm afraid the forum's formatting may make it hard to follow):
*) I think that using "m2_start:" as a label is causing problems, since "m2" is a ShopBot command. Change that to "move_start:" or something like that.
*) add a "GOTO" between the THEN and the labels in your IF tests. So...
"if &m > .5 then start_teeth_loop"
should be...
"if &m > .5 then GOTO start_teeth_loop"
*) You don't need the ":" in the label name in the IF tests, so...
"if [ &spx - %(1) ] * [ &spx - %(1) ] < .001 then dont_lift:"
should be...
"if [ &spx - %(1) ] * [ &spx - %(1) ] < .001 then GOTO dont_lift"
*) You need to use "()" brackets in your nesting and not "[]" brackets
************************************************** *
Here's my mod of your program...see if it does what you expect.
'this is a file containing subroutines for producing three
'dimensional designs using interlocking faces cut out of
'high quality plywood
'
'the command structure should be
'start point x, start point y, end point x, end point y, angle of connection, type of edge, type of material, cutter
&spx = 10
&spy = 10
&epx = 10
&epy = 20
&angle = 90
&type = connect
&material = oak_ply_12_mm
&cutter = unknown
&tooth_count = 7
&cut_count = 3
gosub move_start 'move the cutter to the start point
'loop until we cut down to the veneer
'7 teeth per side
&n = &cut_count '
&m = &tooth_count '
start_cut_loop:
start_teeth_loop:
gosub tooth
&m =&m - 1
if &m > .5 then goto start_teeth_loop
&n = &n - 1
if &n > .5 then goto start_cut_loop
end
move_start:
'check distance to start point
if ( &spx - %(1) ) * ( &spx - %(1) ) < .001 then goto dont_lift
if ( &spy - %(2) ) * ( &spy - %(2) ) < .001 then goto dont_lift
jz .5 'if large distance raise cutter
j2 &spx, &spy 'jog cutter
mz 0 'lower cutter
dont_lift:
if ( %(3) * %(3) ) > .001 then mz 0 'if not at z = zero then go there
return
tooth:
'out part
m2 %(1)+1,%(2) 'cut a straight line
'in part
'pass 1
m2 %(1)+1,%(2) 'continue straight cut
m2 %(1),%(2)+.125 'cut into tooth
m2 %(1)-1,%(2) 'cut back across tooth
m2 %(1),%(2)+.25 'cut further into tooth
m2 %(1),%(2)-.125 'recess for face
m2 %(1)+1,%(2) 'continue straight cut
return
Hope this helps,
Bill
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.