Metalworking (rec.crafts.metalworking) Discuss various aspects of working with metal, such as machining, welding, metal joining, screwing, casting, hardening/tempering, blacksmithing/forging, spinning and hammer work, sheet metal work.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

#!/usr/bin/perl

# If you have a mill with a DRO, and/or a rotary table then you may find
# this script handy when dividing circle. To print the angles (in
# degrees, minutes and seconds) you just specify the number of
# divisions.
#
# If you want to calculate bolt hole pattern given a certain radius
# (assuming that coordinate (0,0) is the center of the circle), you give
# this script an optional argument --radius.
#
# Copyright(C) 2009, Igor Chudov.
# Distributed under the terms of the GNU PUBLIC LICENSE V2
#

use strict;
use warnings;

use Getopt::Long;

my $radius = undef;

GetOptions(
"r|radius=f", \$radius,
);

my $number = shift @ARGV || die "USAGE: $0 number";

$number =~ /^\d+$/ || die "USAGE: $0 number";;

foreach( my $i = 0; $i $number; $i++ ) {
my $angle = 360/$number*$i;

my $degrees = int( $angle );
my $minutes = int( ($angle - $degrees) * 60 );
my $seconds = int( int( ($angle - $degrees - $minutes/60)*60*60 ) );

my $xy = "";
if( $radius ) {
$xy = sprintf( ", x = %.4f, y = %.4f",
$radius * cos( $angle/360 ),
$radius * sin( $angle/360 )
);

}
print sprintf( "%d: %03d %02d' %02d\" (%f) %s\n", $i+1, $degrees, $minutes, $seconds, $angle, $xy );
}
  #2   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

scratch the old version, here's the new one

#!/usr/bin/perl

# If you have a mill with a DRO, and/or a rotary table then you may find
# this script handy when dividing circles. To print the angles (in
# degrees, minutes and seconds) you just specify the number of
# divisions.
#
# If you want to calculate bolt hole pattern given a certain radius
# (assuming that coordinate (0,0) is the center of the circle), you give
# this script an optional argument --radius.
#
# Copyright(C) 2009, Igor Chudov.
# Distributed under the terms of the GNU PUBLIC LICENSE V2
#

use strict;
use warnings;

use Getopt::Long;

my $radius = undef;
my $pi = 3.141592653589793;

GetOptions(
"r|radius=f", \$radius,
);

my $number = shift @ARGV || die "USAGE: $0 number";

$number =~ /^\d+$/ || die "USAGE: $0 number";;

foreach( my $i = 0; $i $number; $i++ ) {
my $angle = 360/$number*$i;

my $degrees = int( $angle );
my $minutes = int( ($angle - $degrees) * 60 );
my $seconds = int( int( ($angle - $degrees - $minutes/60)*60*60 ) );

my $xy = "";
if( $radius ) {
$xy = sprintf( ", x = %.4f, y = %.4f",
$radius * cos( 2*$pi*$angle/360 ),
$radius * sin( 2*$pi*$angle/360 )
);

}
print sprintf( "%d: %03d %02d' %02d\" (%f) %s\n", $i+1, $degrees, $minutes, $seconds, $angle, $xy );
}
  #3   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 1,910
Default Perl script to compute bolt hole pattern

Ignoramus7829 wrote:
#!/usr/bin/perl

# If you have a mill with a DRO, and/or a rotary table then you may find
# this script handy when dividing circle. To print the angles (in
# degrees, minutes and seconds) you just specify the number of
# divisions.
#
# If you want to calculate bolt hole pattern given a certain radius
# (assuming that coordinate (0,0) is the center of the circle), you give
# this script an optional argument --radius.
#
# Copyright(C) 2009, Igor Chudov.
# Distributed under the terms of the GNU PUBLIC LICENSE V2
#

use strict;
use warnings;

use Getopt::Long;

my $radius = undef;

GetOptions(
"r|radius=f", \$radius,
);

my $number = shift @ARGV || die "USAGE: $0 number";


$number = quality variable name.


  #4   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

On 2009-09-04, Cydrome Leader wrote:
my $number = shift @ARGV || die "USAGE: $0 number";


$number = quality variable name.


Update version

#!/usr/bin/perl

# If you have a mill with a DRO, and/or a rotary table then you may find
# this script handy when dividing circles. To print the angles (in
# degrees, minutes and seconds) you just specify the number of
# divisions.
#
# If you want to calculate bolt hole pattern given a certain radius
# (assuming that coordinate (0,0) is the center of the circle), you give
# this script an optional argument --radius.
#
# Copyright(C) 2009, Igor Chudov.
# Distributed under the terms of the GNU PUBLIC LICENSE V2
#

use strict;
use warnings;

use Getopt::Long;

my $radius = undef;
my $pi = 3.141592653589793;

GetOptions(
"r|radius=f", \$radius,
);

my $divisions = shift @ARGV || die "USAGE: $0 number";

$divisions =~ /^\d+$/ || die "USAGE: $0 number";;

foreach( my $i = 0; $i $divisions; $i++ ) {
my $angle = 360/$divisions*$i;

my $degrees = int( $angle );
my $minutes = int( ($angle - $degrees) * 60 );
my $seconds = int( int( ($angle - $degrees - $minutes/60)*60*60 ) );

my $xy = "";
if( $radius ) {
$xy = sprintf( ", x = %.4f, y = %.4f",
$radius * cos( 2*$pi*$angle/360 ),
$radius * sin( 2*$pi*$angle/360 )
);

}
print sprintf( "%d: %03d %02d' %02d\" (%f) %s\n", $i+1, $degrees, $minutes, $seconds, $angle, $xy );
}

  #5   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 3,286
Default Perl script to compute bolt hole pattern

Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.

Karl




  #6   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 6,746
Default Perl script to compute bolt hole pattern


Karl Townsend wrote:

Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.

Karl


Don't most DROs have bolt circle calculator functions built in anyway?
  #7   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

On 2009-09-04, Karl Townsend wrote:
Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.


That's pretty much what the script does, except that you do not need
to run a spreadsheet. It will work if you have Cygwin on Windows or
Activeperl installed.

i
  #8   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 4,562
Default Perl script to compute bolt hole pattern

"Pete C." wrote:

Don't most DROs have bolt circle calculator functions built in anyway?


New ones yes. My ancient Sony DRO's only know how to resolve to the nearest 0.0001" inch.

Overkill on a mill.

Wes
  #9   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 1,852
Default Perl script to compute bolt hole pattern

I have the first edition camel book - how close is this perl...

I have a perl to install but like ghostscript and postscript
I don't write in them, but have the manual :-)

Activeperl - wow - who wrote that!

I remember ftp-ing my copy from JPL. A long time ago. Sun 3 was a hot machine.

Martin

Ignoramus7829 wrote:
On 2009-09-04, Karl Townsend wrote:
Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.


That's pretty much what the script does, except that you do not need
to run a spreadsheet. It will work if you have Cygwin on Windows or
Activeperl installed.

i

  #10   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

fOn 2009-09-05, Martin H. Eastburn wrote:
I have the first edition camel book - how close is this perl...

I have a perl to install but like ghostscript and postscript
I don't write in them, but have the manual :-)

Activeperl - wow - who wrote that!


Activeperl is the easiest way to get perl on windows.

i

I remember ftp-ing my copy from JPL. A long time ago. Sun 3 was a hot machine.

Martin

Ignoramus7829 wrote:
On 2009-09-04, Karl Townsend wrote:
Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.


That's pretty much what the script does, except that you do not need
to run a spreadsheet. It will work if you have Cygwin on Windows or
Activeperl installed.

i



  #11   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 1,417
Default Perl script to compute bolt hole pattern

On Fri, 4 Sep 2009 16:37:33 -0500, "Karl Townsend"
wrote:

Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.

Karl


For those running Windows and don't know what to do with a
Perl script check out Marv Klotz's Utilities:

http://www.myvirtualnetwork.com/mklotz/#shop

He has two versions (maybe more) for doing a similar calc
for bolt circles:

"BOLTCIRC.ZIP (~31 Kbytes) 10/04/05
It's often easier and more accurate to lay out holes on a
boltcircle with x-y coordinates than to scribe and step off
the circle, especially if the number of holes is an unusual
number. This program does the work and generates a table
which you can print and carry to the drill press for
reference. See also CHORD."

"CHORD.ZIP (~19 Kbytes) 02/24/00
For those who insist on marking out subdivisions of a circle
the old-fashioned way and don't want to use BOLTCIRC, this
tool will compute the chord length needed to divide a circle
of input diameter into any number of parts. See also
BOLTCIRC."

--
Leon Fisk
Grand Rapids MI/Zone 5b
Remove no.spam for email
  #12   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 4,562
Default Perl script to compute bolt hole pattern

Ignoramus7829 wrote:

Activeperl - wow - who wrote that!


Activeperl is the easiest way to get perl on windows.


And what is wrong with Cygwin?

Wes
  #13   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 1,852
Default Perl script to compute bolt hole pattern

In the old days it was really a neat trip to install perl on
a unix box. The install was from all sources. It built it on the
fly and while building - it tested and determined - oh 16 bit machine
then oh - bits are reversed Lsb on the left.. and so forth.
Once the library was built, it ran some test cases. Some of those were
interesting to look at and figure how they worked.

We used it as a unix script writer and general good fun.
That is only 25 years ago more or less.

Martin

Ignoramus7829 wrote:
fOn 2009-09-05, Martin H. Eastburn wrote:
I have the first edition camel book - how close is this perl...

I have a perl to install but like ghostscript and postscript
I don't write in them, but have the manual :-)

Activeperl - wow - who wrote that!


Activeperl is the easiest way to get perl on windows.

i

I remember ftp-ing my copy from JPL. A long time ago. Sun 3 was a hot machine.

Martin

Ignoramus7829 wrote:
On 2009-09-04, Karl Townsend wrote:
Iggy, I bet many (like myself) wouldn't know how to run this script or input
data.

I have no real need as I know enough trig
(Some Old Horse Caught Another Horse Taking Oats Away)
to quickly sketch it out and run an excel speadsheet for the calcs.
That's pretty much what the script does, except that you do not need
to run a spreadsheet. It will work if you have Cygwin on Windows or
Activeperl installed.

i

  #14   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 7
Default Perl script to compute bolt hole pattern

On 2009-09-05, Wes wrote:
Ignoramus7829 wrote:

Activeperl - wow - who wrote that!


Activeperl is the easiest way to get perl on windows.


And what is wrong with Cygwin?

Wes


Nothing, I used Cygwin for a while when I was stuck with Windows at
work. Now I use Linux as my desktop OS and can use the real thing
without the pains of Windows (carriage returns, DOS window problems
etc). I have nothing against Cygwin, these guys did a fabulous job.

i
  #15   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 3,286
Default Perl script to compute bolt hole pattern



We used it as a unix script writer and general good fun.
That is only 25 years ago more or less.


So, did you have a T shirt that said, "Grep for it"

DOS had nothing like it at the time.

Karl




  #16   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 1,852
Default Perl script to compute bolt hole pattern

No - Cgrep

#!/usr/bin/perl
$context = 3;
if ($argv[0] =~ /^-(d+)$/) {
$context = $1;
shift;
}
$pat = shift;
$pat =~ S#/#\\/#g;
$_ =;
push($ary,$_);
for (1 .. $context) {
unshift(@ary,''};
}
eval loop_end;
while (\$ary [context]){
if (\$ary[$context] =~ /$pat/) {
print "------\n" if \$seq++;
print \@ary,"\n";
}
\$_ = if \$_;
shift(@ary);
push(\@ary,\$_);
}
LOOP_END

Something like that.

I see it is no longer a camel book - maybe Nutshell 'O'Reilly & Asso, Inc.
has those reserved. I have the 1991 first edition book - in GOOD condition,
but used :-)

Martin

Karl Townsend wrote:
We used it as a unix script writer and general good fun.
That is only 25 years ago more or less.


So, did you have a T shirt that said, "Grep for it"

DOS had nothing like it at the time.

Karl


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Script to track UPS-Packages Ignoramus22443 Metalworking 25 August 17th 07 04:03 AM
Damaged 8mm bolt hole... Best repair? Noozer Home Repair 7 July 4th 06 06:26 PM
layout question - bolt hole pattern [email protected] Metalworking 16 October 4th 05 03:51 PM
DXF drawing of Chev bellhousing bolt pattern Steve Peterson Metalworking 1 March 10th 04 09:00 PM
Is milwaukee router insrt plate mounting hole pattern same as porter cable pattern Rich Woodworking 1 July 22nd 03 04:22 AM


All times are GMT +1. The time now is 01:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 DIYbanter.
The comments are property of their posters.
 

About Us

"It's about DIY & home improvement"