[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: conversion RS274D to RS274X format



On Thu, Apr 21, 2005 at 12:33:30AM -0700, primorec wrote:
> I would like to convert gerber files form RS274D to RS274X format.
> 
> Is there any free program which can do such conversion ?

Someone posted a short perl program which was targeted at PADS
here once.  It shows the basic step you need which is to process
the aperture file and insert the aperture definition codes at 
the top of your RS-274-D file.  It won't cause your file to take
advantage of some of the other RS-274-X features of course, but
it should get you there.  

I'm attaching the script here, but you'll almost certainly need
to hack on it some for your particular aperture file format.
Still, it shouldn't be too hard.  The script is only about a page
long.

-Dan


#!/usr/bin/env perl
#

# pads-d2x

# Converts *.rep files to RS274X header format
# Works for the Xilinx ML300 artwork, allegedly created
# by some flavor of PADS
# http://www.xilinx.com/products/boards/ml300/docs/ML300cpu_gerber.zip

# To convert all the RS274D files in that .zip file to a form usable
# by gerbv-0.16,
# for f in *.pho; do (pads-d2x ${f%.pho}.rep; cat $f) >${f%.pho}.gerb; done  

# Status: "Works for me" [TM]  2004-Sep-02
# Larry Doolittle   <ldoolitt@xxxxxxxxxxxxxxx>

@valid_header=(
 "",
 "",
 "Photo-Plotter Apertures Report",
 "==============================",
 "Position  Width  Hgt/ID  Shape    Qty",
 "========  =====  ======  =====    ===");
while (<>) {
	$line++;
	chomp();
	s/\r$//;
	if ($line < 7) {
		die "file has wrong header" if ($_ ne $valid_header[$line-1]);
		next;
	}
	if ($line == 7) {
		print "\%FSLAX35Y35*\%\n";
		print "G04 Aperture Definitions ***\n";
	}
	@A=split();
	SWITCH: {
		if ($A[3] eq ""    ) {                                                                   last SWITCH; }
		if ($A[3] eq "RND" ) { printf("%%ADD%dC,%.4f*%%\n",      $A[0], $A[1]/1000            ); last SWITCH; }
		if ($A[3] eq "RECT") { printf("%%ADD%dR,%.4f,%.4f*%%\n", $A[0], $A[1]/1000, $A[2]/1000); last SWITCH; }
		if ($A[3] eq "SQR" ) { printf("%%ADD%dR,%.4f,%.4f*%%\n", $A[0], $A[1]/1000, $A[1]/1000); last SWITCH; }
		if ($A[3] eq "OVAL") { printf("%%ADD%dO,%.4f,%.4f*%%\n", $A[0], $A[1]/1000, $A[2]/1000); last SWITCH; }
		print "G04 unknown aperture type $A[3]\n";
	}
}
print "G04 Plot Data ***\n"