/* DUMPPLC (LAY) -- Placement Data Output */ /* DUMPPLC (LAY) -- Platzierungsdatenausgabe */ /* // Copyright (c) 1992-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (111110) ENHANCEMENT: // Added variant specific output options. // rl (101019) RELEASED FOR BAE V7.6. // rl (091020) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (010320) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (000508) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (960919) RELEASED FOR BAE V3.4. // mb (951012) IMPROVEMENT: // Performing BAE_Demo_check(2) before starting output. // mb (95) RELEASED FOR BAE V3.2. // mb (941116) IMPROVEMENT: // Avoid output of default angles and mirror modes. // Introduced option for rounding placement // coordinates to input grid. // mb (94) RELEASED FOR BAE V3.0. // mb (94) CHANGE: // BAE placement data format slightly changed in order // to achieve compatibility with READLPLC and UL Manual. // mb (93) RELEASED FOR BAE V2.6. // mb (93) RELEASED FOR BAE V2.4. // mb (92) RELEASED FOR BAE V2.2. // mb (92) ORIGINAL CODING. // // DESCRIPTION // // The dumpplc User Language program generates placement data // output for the currently loaded layout, whereby the format // can be chosen from generic and BAE placement format. BAE // placement data coordinates may optionally be rounded to the // current X input grid. The output is directed to a file. */ // Includes #include "pop.ulh" // User Language popup utilities #include "lay.ulh" // User Language layout utilities // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_PLCDFEXT "PLCDFEXT_LAY" // Placement dump file name extension // Messages string UPRABORT = M_UPRABORT(); string REPSTART = M("Platzierungsdaten-Ausgabe...", "Placement data output..."); string REPDONE = M("Platzierungsdaten ausgegeben auf Datei '%s'.", "Placement data written to file '%s'."); string UPRFORMAT = M("Ausgabe-Format selektieren!", "Select Output Format!"); string UPRFMTGEN = M("&Generisches Format Alles","&Generic Format All"); string UPRFMTBAE = M("&BAE Format Alles","&BAE Format All"); string UPRFMTGENV = M("%G&enerisches Format Variante", "G&eneric Format Variant"); string UPRFMTBAEV = M("B&AE Format Variante","B&AE Format Variant"); string UPRSHIFT = M("Platzierungsdaten auf %f %s runden ? ", "Round Placement Data to %f %s ? "); // Output format strings #define FMTGENERIC "%s\t%s\t%8.3f %8.3f %7.3f %d\n" #define FMTHEADER "%s '%s' ;\n" #define FMTUNITHD "\nUNITS {\n" #define FMTUNITL " LENGTH = ( %.10f %s ) ;\n" #define FMTUNITA " ANGLE = ( 1.0 DEGREE ) ;\n" #define FMTPLCHD "\nPLACEMENT {\n" #define FMTPART " '%s'\t: '%s' {\n" #define FMTPOS " POSITION = (%5.3f,%5.3f) ;\n" #define FMTROT " ROTATION = %6.3f ;\n" #define FMTMIRROR " MIRROR = %d ;\n" #define FMTPRTEND " }\n" #define FMTBLKEND " }\n" #define FMTTERM "\nEND\n" #define ITMLAYOUT "LAYOUT" #define ITMPART "PART" #define ITMUNITIN "INCH" #define ITMUNITMM "MM" // Globals string PDEXT = bae_inistrval(PAR_PLCDFEXT,".plc") /* Place file name extension */; #define FTYPGEN 0 // Format type generic #define FTYPBAE 1 // Format type BAE int FTYP /* Output format type */; int VAROUT = 1 /* Variant parts only output flag */; int SHIFT /* Placement data shift flag */; double XGRID /* Current X input grid */; string classname /* Plan class name */; int varnum /* Variant number */; // Main program void main() { string jobfname /* Job file name */; string placefname /* Place file name */; int placefh /* Place file handle */; // Get the class denoter switch (bae_planddbclass()) { case DDBCLLAY : classname=ITMLAYOUT; break; case DDBCLLPRT : classname=ITMPART; VAROUT=0; break; // No valid element default : error_class(); } // Perform BAE Demo check with abort option BAE_Demo_check(2); // Ask for output format bae_promptdialog(UPRFORMAT); switch (bae_askmenu(5, UPRFMTGEN,UPRFMTBAE,UPRFMTGENV,UPRFMTBAEV,UPRABORT)) { // Generic format case 0 : VAROUT=0; case 2 : FTYP=FTYPGEN; break; // BAE format case 1 : VAROUT=0; case 3 : FTYP=FTYPBAE; // Get input grid bae_getinpgrid(XGRID,0); // Verify if placement data shift is required if (XGRID!=0.0) sprintf(jobfname,UPRSHIFT,baecvtl(XGRID), bae_getcoorddisp() ? ITMUNITIN : ITMUNITMM); SHIFT=verify(jobfname,1); break; // Abort on default default : error_abort(); } // Get the plan file name jobfname=bae_planfname(); // Build the placement data file name placefname=convstring(jobfname,0)+PDEXT; // Start output bae_prtdialog(REPSTART); // Open the placement data file placefh=bae_fopen(placefname,1); // Query the current active variant if (lay_rulequery(RS_OCPLAN,0,RS_PCBSUBJ,RS_VARIANT,"?d",varnum)<1) // Use base variant varnum=0; // Test the format type if (FTYP==FTYPGEN) // Write the generic format placement data genplacement(placefh,bae_planwsnx(),bae_planwsny()); else if (FTYP==FTYPBAE) // Write the BAE format placement data baeplacement(placefh,bae_planwsnx(),bae_planwsny()); // Close the placement data file fclose(placefh); // Done message(REPDONE,placefname); } void genplacement(int fh,double nx,double ny) /* // Write the generic format placement data // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_NREF nref /* Named reference index */; // Loop thru the named reference list forall (nref where placestat(nref.NAME)) // Write the part entry fprintf(fh,FMTGENERIC,nref.NAME,nref.MACRO.NAME, cvtlength(nref.X-nx,0,2),cvtlength(nref.Y-ny,0,2), cvtangle(nref.ANGLE,0,1),nref.MIRROR); } void baeplacement(int fh,double nx,double ny) /* // Write the BAE format placement data // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_NREF nref /* Named reference index */; int xi,yi /* (Rounded) integer coordinates */; // Write the data file header fprintf(fh,FMTHEADER,classname,bae_planename()); // Write the units section fprintf(fh,FMTUNITHD); fprintf(fh,FMTUNITL,SHIFT ? baecvtl(XGRID) : 1.0, bae_getcoorddisp() ? ITMUNITIN : ITMUNITMM); fprintf(fh,FMTUNITA); fprintf(fh,FMTBLKEND); // Write the placement section fprintf(fh,FMTPLCHD); forall (nref where placestat(nref.NAME)) { // Write the part entry fprintf(fh,FMTPART,nref.NAME,nref.MACRO.NAME); // Write the placement coordinates if (SHIFT) { // Round output coordinates xi=(nref.X-nx)/XGRID+0.5; yi=(nref.Y-ny)/XGRID+0.5; fprintf(fh,FMTPOS,xi,yi); } else // Direct coordinate output fprintf(fh,FMTPOS, baecvtl(nref.X-nx),baecvtl(nref.Y-ny)); // (Optionally) write the rotation angle if (nref.ANGLE!=0.0) fprintf(fh,FMTROT,cvtangle(nref.ANGLE,0,1)); // (Optionally) write the mirror mode if (nref.MIRROR) fprintf(fh,FMTMIRROR,nref.MIRROR); // Write the part entry terminator fprintf(fh,FMTPRTEND); } // Write the block terminator fprintf(fh,FMTBLKEND); // Write the data file terminator fprintf(fh,FMTTERM); } int placestat(string partname) /* // Get part placement status // Return value : // one if part placed, else zero // Parameters : // string partname : Part name name */ { index L_CPART part /* Part index */; index L_ATTRIBUTE att /* Attribute index */; string vattname /* Variant attribute name */; string attval = "" /* Attribute value */; // Check if any part output or constructive part if (!VAROUT || lay_findconpart(partname,part)) return(1); // Build the variant attribute name vattname=varattrname("$noplc",varnum); // Search for first attribute forall (att of part where att.NAME==vattname || att.NAME=="$noplc") { // Store the base variant attribute value attval=att.VALUE; // Check if active variant attribute if (att.NAME==vattname) // Attribute value found break; } return(attval!="" ? 0 : 1); } // User Language program end