Creating Output from GDL Object Hierarchies =========================================== Output formats can be used in conjunction with the "with-format" macro to produce customized output from GDL objects, as shown in the examples below. If you create new GDL objects, you can also create output-functions for your new object for the various formats by using the define-view macro, for example: (define-view (pdf my-widget)() :output-functions ((cad-output () (pdf:move-to (the start)) (pdf:line-to (the end))))) Please see the reference documentation for define-view for more details. 1 PDF ===== PDF is the native graphics and document format of GDL and as such is the most developed. Most graphical and textual objects in GDL have PDF views defined for them with at least a "cad-output" method. The term "cad-output" is somewhat dated, as the output could refer to a paper report with charts and graphs as much as a drawing of mechanical parts, so these names may be refined in future GDL releases. Here is an example of producing a PDF of the built-in robot assembly: (with-format (pdf "/tmp/robot.pdf" :page-length (* 6.5 72) :page-width (* 8.5 72) :view-transform (getf *standard-views* :trimetric) :view-scale 37) (write-the-object (make-object 'gwl-user::robot-assembly) (cad-output-tree))) Available slots for the PDF writer and their defaults: (page-width 612) (page-length 792) (view-transform (getf *standard-views* :top)) (view-center (make-point 0 0 0)) ;; in page coordinates (view-scale 1) 2 DXF ===== DXF is AutoCAD's drawing exchange format. Currently most of the geometric objects and drawing and text objects have a cad-output method for this output-format. The GDL DXF writer currently outputs a relatively old-style AutoCAD Release 11/12 DXF header. In future GDL versions this will be switchable to be able to target different release levels of the DXF format. Here is an example of producing a DXF of the built-in robot assembly: (with-format (dxf "/tmp/robot.dxf" :view-transform (getf *standard-views* :front) :view-scale 37 :view-center (make-point 0 0 0)) (write-the-object (make-object 'gwl-user::robot-assembly) (cad-output-tree))) Note that the DXF writer is currently 2D in nature and therefore takes a :view-transform to specify a view plane onto which all 3D entities are projected. A 3D version of the DXF writer will be available in a future GDL release. Available slots for the PDF writer and their defaults: (view-transform (getf *standard-views* :top)) (view-center (make-point 0 0 0)) ;; in page coordinates (view-scale 1) 3 vrml ====== GDL currently contains a rudimentary VRML writer which maps GDL primitive geometric objects (boxes, spheres, etc) into their VRML equivalents. Future GDL releases will include more object types and mechanisms to specify viewpoints, lighting, textures, etc. (with-format (vrml "/tmp/robot.wrl") (write-the-object (make-object 'gwl-user::robot-assembly) (world))) 4 html-format ============= The HTML output format is used extensively throughout GWL for generating dynamic web page hierarchies corresponding to GDL object hierarchies. Please refer to the GDL Tutorial, gwl-usage.txt, and gwl-reference.txt for extensive examples of using this output format. 5 iges ====== 5.1 overview ============ We supply an IGES output-format with the optional GDL NURBS Surfaces Facility. The IGES format will also convert certain GDL wireframe primitives into appropriate curve and surface objects for IGES output (e.g. l-lines into linear-curves, arcs into arc-curves). Here are some examples of simple use: (with-format (iges "/tmp/try.iges") (write-the cad-output-tree)) (with-format (iges "/tmp/try.iges") (write-the cad-output)) 5.2 brep solids representation in iges ====================================== For breps, you can output them as individual breps or as a bag of the faces (trimmed surfaces) making up the brep. This is done with the format variable :breps-format, which can have the value :breps (the default) or :surfaces, e.g. (with-format (iges "/tmp/try.iges" :breps-format :surfaces) ...) ;; or (with-format (iges "/tmp/try.iges" :breps-format :breps) ...) 5.3 units in iges ================== The iges units can be specified with the format variable :units, e.g: (with-format (iges "/tmp/try.iges" :units :millimeters) ...) ;; or (with-format (iges "/tmp/try.iges" :units :feet) ...) ;; or The allowed values for :units are the keyword symbols in the following list: (:inches :millimeters :feet :miles :meters :kilometers :mils :microns :centimeters :microinches :no-units-specified) The default is :inches.