|
NAMECAD::Drawing::Template - Replace tags with text and geometry.SYNOPSISmy $bp = CAD::Drawing::Template->new(); $bp->load('my_template.dxf'); # set some values for the boiler-plate: $bp->set_data(foo => 'value for foo'); my @parts = qw(E8955 Q4200); $bp->set_vtable(parts => \@parts); $bp->set_geom(birdseye => 'birdseye.dwg'); my $drw = $bp->done(pass => qr/^shipping/, die => 0); $drw->save('output.dxf'); Input TemplatesInput templates must be CAD::Drawing compatible files or objects. These are brought into the CAD::Drawing::Template object via load() or import() and searched for 'texts' items which match the formats listed below.The tags may be on any layer in the drawing except 'comments' and 'fit' which are reserved names. The 'comments' layer is completely discarded, and the 'fit' layer must only contain rectangles (which are necessary for scaling calculations, but are also discarded.) Tag FormatsThe 'tags' are 'texts' entities (single-line text in dwg/dxf formats) which must begin and end with matching angle-brackets ('<' and '>'.) These text entities are sourced for their insertion point, text height, and name. Future versions of this module will support orientations, fonts, and options within the tag text itself.In general, tags are formatted as <$type:$name>. Where $type is one of the types defined below and $name is the name of the tag (to be used in addressing it via the set_*() functions. Tag names should adhere to the same rules as perl variable names: 1. Alphanumeric characters (and underscores) only (a-z, A-Z, 0-9, _) 2. Must start with a letter ("a2", not "2a", and not "_2") 3. Case senSitive The following tag types are supported. Examples show the text string that would be in the template.
AUTHOREric L. Wilhelm <ewilhelm at cpan dot org>http://scratchcomputing.com COPYRIGHTThis module is copyright (C) 2004-2006 by Eric L. Wilhelm.LICENSEThis module is distributed under the same terms as Perl. See the Perl source package for details.You may use this software under one of the following licenses: (1) GNU General Public License (found at http://www.gnu.org/copyleft/gpl.html) (2) Artistic License (found at http://www.perl.com/pub/language/misc/Artistic.html) ModificationsThe source code of this module is made freely available and distributable under the GPL or Artistic License. Modifications to and use of this software must adhere to one of these licenses. Changes to the code should be noted as such and this notification (as well as the above copyright information) must remain intact on all copies of the code.Additionally, while the author is actively developing this code, notification of any intended changes or extensions would be most helpful in avoiding repeated work for all parties involved. Please contact the author with any such development plans. SEE ALSOCAD::Drawing Constructorsnewmy $bp = CAD::Drawing::Template->new(%options);
cloneDuplicates the boiler-plate as a snapshot in time (useful to save effort in loops.)my $bp2 = $bp->clone(); Template HandlingGetting template data in and finished data out.load$bp->load($filename); # or: $bp->load($drawing_object); done$drw = $bp->done(%options); Options: pass - array ref of pass-able tags ("type:name" strings) strict - croak on tags not listed in pass warnings - carp warnings default - "drop" or "pass" (default) action for un-passed tags tag_list$bp->tag_list(); MethodsThese methods allow you to manipulate the template.set_dataReplace the tag's text with a string.$bp->set_data($name => $value); # replace the tag <data:department> with the department's name: $dep = 'Department of Redundancy Department'; $bp->set_data(department => $dep); set_vtableRemove the tag entity, and create a series of texts, each spaced slightly below the previous.$bp->set_vtable($name => \@list); # uses the tag: <vtable:revision> # create a table of revision notes: my @rev = ( ' 1 Changed fonts for PHB', ' 2 Changed fonts back (for same)', ' 3 Removed all text', ); $bp->set_vtable(revision => \@rev); set_geoLoad a drawing into the template, scaling it to fit within an enclosing rectangle.$bp->set_geo($name => $filename); # or: $bp->set_geo($name => $drawing_object); set_blockIdentical to set_geo, except no scaling is performed.$bp->set_block($name => $filename); # or: $bp->set_block($name => $drawing_object); GutsThese methods are used internally.find_tagsGrabs the addresses of all tags which match the regex m/^<.*>$/. Any which were are in the array @{$self->{pass}} are left untouched.After finding all of the tags, execute any <function:*> tags which were found. $bp->find_tags(); geo_matchPerforms the rectangle-tag matching. Must be able to reduce each geo tag to an innermost enclosing rectangle or dies with much whining.$bp->geo_match(); run_functionRuns the function $name (in a list context) and places it's results (joined with spaces) into the string at $addr.$bp->run_function($name, $addr); load_drawingLoads a drawing from a filename or CAD::Drawing object and returns a CAD::Drawing object.$drw = $bp->load_drawing($name => $filename); # or: $drw = $bp->load_drawing($name => $drawing_object); FunctionsNot object-oriented, and likely not exported.parse_tagBreak a tag into type, name, and options. When (and if) options are supported within the tags, they will be handled here.($type, $name, $options) = parse_tag($tag);
Visit the GSP FreeBSD Man Page Interface. |