Place more than one (same !) PCB at the time
Re: Place more than one (same !) PCB at the time
for anyone that wants to play with it, here is the perl script. It is very basic! It doesn't even ask command line arguments yet, just expects files to exist with the right filenames ... but it's a start
-
- Posts: 32
- Joined: Sun Apr 05, 2015 5:51 pm
Re: Place more than one (same !) PCB at the time
Hello Daniel,
Were can I find or download your script? I want to try the script with the file I gave you previously.
Were can I find or download your script? I want to try the script with the file I gave you previously.
Re: Place more than one (same !) PCB at the time
hmmm. I thought I attached it to the last post. I'll try again. If this doesn't work, I'll mail you ...!
OK, extension not allowed. Here it is then. This was written on windows. On unix/linux, you should add the shebang line, but I think most people here will run it on windows. I recommend Strawberry Perl, but ActiveState should work too.
====
use strict;
use warnings;
my @headings;
my @boards;
my $compfile = "components.txt";
my $boardsfile = "boards.txt";
my $outfile = "multiply.txt";
my $count = 0;
print "PROCESSING BOARDS from $boardsfile\n\n";
open (my $bf, "<", $boardsfile) or die "Could not open $boardsfile - $!";
while (my $board = <$bf>){
$count++;
chomp $board;
my @rxy = split(' ', $board);
my $fields = scalar @rxy;
unless ($fields == 3) {
die "line $count of $boardsfile has $fields fields, expected 3";
}
push @boards, \@rxy;
print "Added board ref:\t".$rxy[0]."\tX:\t".$rxy[1]."\tY=\t".$rxy[2]."\n";
}
close $bf;
print "$count boards added.\n\n";
$count = 0;
open (my $out, ">", $outfile);
print "PROCESSING COMPONENTS from $compfile\n\n";
open (my $cf, "<", $compfile) or die "Could not open $compfile - $!";
while (my $component = <$cf>){
$count++;
chomp $component;
next if $component =~ /^-/;
my @values;
if ($count == 1){ #process header line
@headings = split(' ', $component);
unless ( grep( /^X$/, @headings) &&
grep( /^Y$/, @headings) &&
grep( /^Component$/, @headings)){
print "$component\n";
close $out;
close $cf;
die "Line 1 (header) of $compfile must contain 'X' and 'Y' (in upper case), and 'Component'.\n";
}
print $out "$component\n";
} else { #process component
@values = split(' ', $component);
unless ( scalar @values == scalar @headings ){
print "$component\n";
die "wrong number of values at line $count of $compfile";
}
# now print a component line for each board
for ( my $b = 0; $b < scalar @boards; $b++){
my $board = $boards[$b]; # array ref
for ( my $hpos =0; $hpos < scalar @headings; $hpos++){
my $h = $headings[$hpos];
my $v = $values[$hpos];
if ($h eq 'Component'){
$v .= "_";
$v .= $board->[0];
} elsif ($h eq 'X') {
$v = $v + $board->[1];
} elsif ($h eq 'Y') {
$v = $v + $board->[2];
}
print $out "$v\t";
}
print $out "\n";
}
}
}
close $cf;
close $out;
OK, extension not allowed. Here it is then. This was written on windows. On unix/linux, you should add the shebang line, but I think most people here will run it on windows. I recommend Strawberry Perl, but ActiveState should work too.
====
use strict;
use warnings;
my @headings;
my @boards;
my $compfile = "components.txt";
my $boardsfile = "boards.txt";
my $outfile = "multiply.txt";
my $count = 0;
print "PROCESSING BOARDS from $boardsfile\n\n";
open (my $bf, "<", $boardsfile) or die "Could not open $boardsfile - $!";
while (my $board = <$bf>){
$count++;
chomp $board;
my @rxy = split(' ', $board);
my $fields = scalar @rxy;
unless ($fields == 3) {
die "line $count of $boardsfile has $fields fields, expected 3";
}
push @boards, \@rxy;
print "Added board ref:\t".$rxy[0]."\tX:\t".$rxy[1]."\tY=\t".$rxy[2]."\n";
}
close $bf;
print "$count boards added.\n\n";
$count = 0;
open (my $out, ">", $outfile);
print "PROCESSING COMPONENTS from $compfile\n\n";
open (my $cf, "<", $compfile) or die "Could not open $compfile - $!";
while (my $component = <$cf>){
$count++;
chomp $component;
next if $component =~ /^-/;
my @values;
if ($count == 1){ #process header line
@headings = split(' ', $component);
unless ( grep( /^X$/, @headings) &&
grep( /^Y$/, @headings) &&
grep( /^Component$/, @headings)){
print "$component\n";
close $out;
close $cf;
die "Line 1 (header) of $compfile must contain 'X' and 'Y' (in upper case), and 'Component'.\n";
}
print $out "$component\n";
} else { #process component
@values = split(' ', $component);
unless ( scalar @values == scalar @headings ){
print "$component\n";
die "wrong number of values at line $count of $compfile";
}
# now print a component line for each board
for ( my $b = 0; $b < scalar @boards; $b++){
my $board = $boards[$b]; # array ref
for ( my $hpos =0; $hpos < scalar @headings; $hpos++){
my $h = $headings[$hpos];
my $v = $values[$hpos];
if ($h eq 'Component'){
$v .= "_";
$v .= $board->[0];
} elsif ($h eq 'X') {
$v = $v + $board->[1];
} elsif ($h eq 'Y') {
$v = $v + $board->[2];
}
print $out "$v\t";
}
print $out "\n";
}
}
}
close $cf;
close $out;
Re: Place more than one (same !) PCB at the time
Rinus, I also mailed it to you.
-
- Posts: 32
- Joined: Sun Apr 05, 2015 5:51 pm
Re: Place more than one (same !) PCB at the time
thanks, I found it in my mailbox, it will take some time for me to get used to the 'perl-world' I never used it before.
I guess it's not possible to compile the script to an windows executable?
I guess it's not possible to compile the script to an windows executable?
Re: Place more than one (same !) PCB at the time
> OK, extension not allowed.
Hmm. As far as I can see, no restrictions are active. I don't know why it wouldn't work.
Hmm. As far as I can see, no restrictions are active. I don't know why it wouldn't work.
Re: Place more than one (same !) PCB at the time
It is, but it would still be command line. And to be honest I have never bothered. All you need to do:RinusDamen wrote:thanks, I found it in my mailbox, it will take some time for me to get used to the 'perl-world' I never used it before.
I guess it's not possible to compile the script to an windows executable?
1. install strawberry perl
2. put the script in a folder somewhere
3. put your p&p file in that same folder, rename it "components.txt"
4. write your "boards.txt" file in that folder with notepad or some other plain text editor
5. on a command line in that folder type "panelise.pl" (or you might be able to just double click the script)
6. That should create (silently deleting any file of the same name that was there before) a file called "multiply.txt" with the output.
like I said, it's very basic, but if the concept works I can make it a bit "prettier" later. Or whatever ...
Re: Place more than one (same !) PCB at the time
maybe in the webserver config? sometimes they don't like the look of scripts anyway, no big deal. Let's try renaming ... also "The extension txt is not allowed" for "panelise-pl.txt" ... and also "The extension is not allowed"when I try "panelise-pl" ... ok, whatever. Your BB software hates meJuKu wrote:> OK, extension not allowed.
Hmm. As far as I can see, no restrictions are active. I don't know why it wouldn't work.
Re: Place more than one (same !) PCB at the time
I'm supposed to be in control... Are the machines finally taking over?