Plotting a Map

AutoCAD Map 3D AutoLISP

Up a level
Plotting a Map

Plotting is the last stage in presenting map data.

The following sample outlines the steps required to set up and plot a map set.

To plot a map
  1. Set the Plotter name for Layout1 using the AutoCAD� ActiveX� interface.
  2. (vl-load-com)
    (setq acadObject (vlax-get-Acad-object))
    (setq acadDocument (vla-get-ActiveDocument acadObject))
    (setq activeLayoutObject (vla-Get-ActiveLayout acadDocument))
    (setq pSpace (vla-get-PaperSpace acadDocument))
    (setq layout (vla-get-layout pSpace))
    (vla-put-configname layout "\\\\PlotServer\\Hp Laserjet 4100 Series Pcl")
  3. Add a drive alias to the list so that AutoCAD Map can find the drawings used to execute the plot.
  4. (ade_aliasadd "LISP_SAMPLE" "C:\\Lisp\\Drawings\\PlotMapSet")
  5. Define a boundary drawing or use an existing one. This example uses an existing drawing named System-Grid.dwg.
  6. The boundary drawing must contain at least one closed polyline with object data. Each closed polyline is a division of the map, and the sheet name is attached to it as object data.

  7. Attach the drawings for this plot set and the boundary drawing.
  8. (ade_dsattach "LISP_SAMPLE:\\Landbase-Shared.dwg")
    (ade_dsattach "LISP_SAMPLE:\\Water-Facilities.dwg")
    (ade_dsattach "LISP_SAMPLE:\\System-Grid.dwg")
  9. Define a "Draw" mode query which selects "ALL" objects in the attached drawings.
  10. (ade_qryclear)
      '("" "" "" "Location" ("All") "" ))
    (ade_qrysettype "draw")
  11. Save the query internal to the project.
  12. (ade_qrysave "PlotQueries"
      '(("name" "TruckBook-100") ("saveoption" 2)))
  13. Define a layout block, (title block) or use an existing one. The layout block must contain at least one viewport and optionally a reference viewport. If the layout block contains an attribute which represents a mapname or some other type of area naming convention, that name can be mapped from the boundary drawing to this attribute, in fact any object data associated to a boundary can be mapped to an attribute on the layout block. This sample does not contain code for creating or defining this layout block.
  14. Create a new plot set.
  15. (map_pltCurrDef "TruckBook-100")
  16. Define Plot Set variables
  17. Define the drawing set:

    (setq dwgs_list
    (list "LISP_SAMPLE:\\Landbase-Shared.dwg" "LISP_SAMPLE:\\Water-Facilities.dwg"))
    (map_pltCurrSet "dwgs" dwgs_list)

    Define the plotter name via the layout:

    (map_pltCurrSet "pnam" "Layout1")

    Define the layout block name:

    (map_pltCurrSet "block" "TITLE-A")

    Define the layout blocks viewport layer:

    (map_pltCurrSet "vlayer" "TB-BORDER")

    Define the object data table containing boundary information:

    (map_pltCurrSet "bnamt" "MAPSYS-MAP")

    Define the boundary field name:

    (map_pltCurrSet "bnamf" "MAPNAME")

    Define the boundary object data field to block attribute in layout mapping:

    (map_pltCurrSet "atts" "MAPNAME")

    Define the layout blocks reference viewport flag:

    (map_pltCurrSet "kflg" nil)

    Define the layout blocks key viewport layer:

    (map_pltCurrSet "klayer" "")

    Define the display layers in the reference viewport:

    (map_pltCurrSet "kdispl" "")

    Define the layers to freeze in main viewport:

    (map_pltCurrSet "vdispl" "0")

    Define the query category:

    (map_pltCurrSet "qcat" "PlotQueries")

    Define the query name:

    (map_pltCurrSet "qnam" "TruckBook-100")

    Define the boundary drawing:

    (map_pltCurrSet "bdwg" "LISP_SAMPLE:\\System-Grid.dwg")

    Define the boundary layer:

    (map_pltCurrSet "blyr" "MAPEDGE")

    Define the boundary field name:

    (map_pltCurrSet "bodfs" "MAPNAME")

    Specify the boundaries:

    (setq bndry_list (list "101" "102"))
    (map_pltCurrSet "bnds" bndry_list)

    Define the plot to specified scale flag:

    (map_pltCurrSet "sflg" nil)

    Define the plot scale:

    (map_pltCurrSet "scale" "1:750")

    Define the clip objects against boundary flag:

    (map_pltCurrSet "clip" T)

    Define the plot the boundary flag:

    (map_pltCurrSet "pbnd" T)
  18. Append the current plot set definition to the plot set list.
  19. (map_pltCurrSave)
  20. Write the current plot set definition to the plot definition dictionary within the currrent project.
  21. (map_pltDefSave)
  22. Perform a cursory check to see if the required attributes have been set, this is optional.
  23. (if (not (map_pltDefValid "TruckBook-100"))
        (prompt "\nERROR: Plot set invalid.")
  24. Perform a more extensive check that makes sure that no errors occur when plotting takes place, this is optional.
  25. (map_pltdefverify "TruckBook-100")
  26. Initialize the plotting environment. See (map_pltInit) for more detail on this function.
  27. (map_pltInit)
  28. Display a single sheet within the plot set based on a boundary value, then plot if successful. Note, you must always call map_pltdisplay() before calling map_pltPlot().
  29. (map_pltDisplay "101")
    ;Visually check the plot set display. If it is correct, plot it.
    (initget "Yes No")
    (setq answer
          (getkword "\nDisplay is correct Yes/No  ?"))
    (if (or (null answer) (equal answer "Yes"))
  30. Restore the display environment to its state before the last execution of the map_pltDisplay().
  31. (map_pltRestore)
  32. Restore the data extension options and AutoCAD settings altered by map_pltInit().
  33. (map_pltCleanup)