GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
CAD::Drawing::Template(3) User Contributed Perl Documentation CAD::Drawing::Template(3)

CAD::Drawing::Template - Replace tags with text and geometry.

  my $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 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.)

The '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.

data
A 'data' tag is replaced with a single scalar value.

Examples:

  <data:department>
  <data:item_code>
  <data:A5>
    
vtable
A 'vtable' tag is replaced with a list of values, each one some distance below the previous, with the top line's insertion point at the tag's insertion point.

Examples:

  <vtable:revision>
  <vtable:part_list>
    
geo
Loads a drawing and fits it into a rectangle.

NOTE: The rectangle must be on a layer named 'fit' and contain the insertion point of the tag. Each <geo:name> tag must be within a rectangle on the 'fit' layer and each rectangle on the 'fit' layer must have exactly one <geo:name> tag inside of it. If this is not true, death ensues. These rectangles are removed from the drawing before output.

While a rectangle may contain two 'geo' tags, each tag must be contained in one rectangle (the innermost containing rectangle wins.)

Examples:

  <geo:section>
  <geo:isometric>
    
block
Loads a drawing to the insertion point.

Examples:

  <block:north_arrow>
  <block:scale>
    
function
A 'function' tag calls a perl function, and afterwards behaves like a data tag. There is no set_function() function, since this tag is supposed to be fully-automatic.

The function is assumed to be a member of a Perl module. If that module is not already loaded, it is require()'d within an eval() statement before the function is called. There is no provision for passing values to these functions. The function is called in a list context, and the results joined by spaces. Any errors encountered in calling the function will be croak()'d along with the function name.

If the module is contained under a non-standard path (one which is not included in @INC), it should be preceded by a directory path. This directory is then brought into @INC via the 'use lib' pragma.

Examples:

  <function:date>                  # uses main::date()
  <function:Date::Calc::Today>
  <function:CAD::Calc::pi>
  <function:my_perl_lib/Functions::foo>
    

Eric L. Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com

This module is copyright (C) 2004-2006 by Eric L. Wilhelm.

This 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)

The 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.

  CAD::Drawing

  my $bp = CAD::Drawing::Template->new(%options);
Valid options
  pass => [@list], # type:name strings only
    

Duplicates the boiler-plate as a snapshot in time (useful to save effort in loops.)

  my $bp2 = $bp->clone();

Getting template data in and finished data out.

  $bp->load($filename);
  # or:
  $bp->load($drawing_object);

  $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

  $bp->tag_list();

These methods allow you to manipulate the template.

Replace 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);

Remove 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);

Load 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);

Identical to set_geo, except no scaling is performed.

  $bp->set_block($name => $filename);
  # or:
  $bp->set_block($name => $drawing_object);

These methods are used internally.

Grabs 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();

Performs 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();

Runs 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);

Loads 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);

Not object-oriented, and likely not exported.

Break 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);
2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.