| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use CNC::Cog; | ||
| 4 | use CNC::Cog::Gdcode; | ||
| 5 | use CNC::Cog::Gcode; | ||
| 6 | |||
| 7 | my %opt; | ||
| 8 | $opt{allowed}='p'; | ||
| 9 | @ARGV=grep { s/^-([$opt{allowed}])//?(($opt{$1}=1)&&0):1 } @ARGV; | ||
| 10 | grep { m/^-/ } @ARGV and die "Illegal option in @ARGV"; | ||
| 11 | |||
| 12 | my ($g); | ||
| 13 | if ($opt{p}) | ||
| 14 | { | ||
| 15 | $g=new Gdcode("test.png",1.25,400,400); # this uses the GD module to generate a .png file | ||
| 16 | } | ||
| 17 | else | ||
| 18 | { | ||
| 19 | my $feed=5.0; # feed rate for cut. | ||
| 20 | $g=new Gcode("test.ngc",$feed); # and this produces gcode in the file test.ngc. | ||
| 21 | } | ||
| 22 | |||
| 23 | $c=newcogpair Cog(1.6,9,16); # Creates a pair of meshing wheels, with teeth module 1.6 (mm) one with 9, one with 16 teeth. | ||
| 24 | $c->{wheel}->cutset(0.0625,4,-0.0125); # cuttersize, passes, passdepth | ||
| 25 | |||
| 26 | $c->{pinion}->{passes}=8; # need more depth on pinion. | ||
| 27 | $c->{pinion}->{fillet}=1; | ||
| 28 | |||
| 29 | $s=new Stack(0.125,4,-0.025); # $cuttersize,$passes,$passdepth,$facedepth | ||
| 30 | $boss=new Boss(0.125,8,-0.0125,0.13); | ||
| 31 | $boss->{name}='Jim'; # used in comments in gcode | ||
| 32 | |||
| 33 | $c->{pinion}->{name}='pinion'; # used in comments | ||
| 34 | $c->{wheel}->{name }='wheel'; # used in comments | ||
| 35 | |||
| 36 | $s->add($boss,$c->{pinion},$c->{wheel}); | ||
| 37 | |||
| 38 | |||
| 39 | $g->ginit(); | ||
| 40 | $s->cut($g,0,0,0); | ||
| 41 | $g->gend(); |