CD - Canvas Draw

MicroStation Design File Driver (cddgn.h)

This driver allows generating a MicroStation design file. The file name usually has an extension .DGN. The driver supports only MicroStation version 4.0 or later. The format's copyrights are property of Bentley Systems.


Use

The file is created and opened by calling function cdCreateCanvas(CD_DGN, Data), in which Data contains the filename and canvas dimensions. This function opens the file and writes its header. Then, other functions in the CD library can be called as usual. The Data parameter string has the following format:

"filename [widthxheight] [resolution] [-f] [-sseedfile]" or in C "%s %gx%g %g %s"

Only the parameter filename is required. Width and height are provided in millimeters (note the lowercase "x" between them), and their default value in pixels is INT_MAX for both dimensions. Resolution is the number of pixels per millimeter; its default value is "3.8". Width, height and resolution are real values. Parameter -f modifies the polygon filling's behavior. Just as in MicroStation, you can specify a seed file using parameter -s. Width, height and resolution are used only by cdGetCanvasSize and in pixel-millimeter conversion. 

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to close the file properly.

Images and Colors - The DGN format does not support server images and works with an indexed-color format. Color quality is limited to 256 colors, and the format uses a uniform palette to convert RGB colors into palette indices. If you configure a palette, the color conversion process will become slower.

Filling - Up to version 5.0, MicroStation presents some limitations for polygon filling. You can disable filling by means of string "-f" in the Data parameter. Filled polygons can only have around 10,000 vertices; if the value is larger, the polygon style changes to closed lines.

Seed - In the seed file, several DGN parameters can be defined to be used in the drawing. The library offers a default seed file, called SEED2D.DGN. The file's location depends on the environment variable CDDIR.


Behavior of Functions

Control

Coordinate System and Clipping

  • cdClip: does nothing (no clipping function is supported), returns CD_CLIPOFF.
  • cdClipArea: does nothing.
  • cdGetClipArea: does nothing, returns CD_CLIPOFF.
  • cdUpdateYAxis: does nothing. The axis orientation is the same as the CD library.

Primitives

  • cdBegin: if parameter CD_CLIP is specified, does nothing.
  • cdMark: is simulated.

Attributes

  • cdBackOpacity: does nothing, returns CD_OPAQUE.
  • cdWriteMode: does nothing, returns CD_REPLACE.
  • cdInteriorStyle: does nothing.
  • cdHatch: does nothing (to be implemented).
  • cdStipple: does nothing (to be implemented).
  • cdPattern: does nothing (to be implemented).
  • cdTextSize: returns a bounding box which is usually larger than the text (the computation is based on the widest character).
  • cdTextAlignment: uses cdTextSize, therefore is not precise.
  • cdNativeFont: selects the font number defined in MicroStation ("%d" in C style).
  • cdFont: See the font mapping table for the equivalence used to map CD fonts into MicroStation fonts:
Font Mapping
CD Fonts MicroStation Fonts
CD_SYSTEM / CD_HELVETICA #0 - Standard
CD_COURIER #43 - Low_res_filled
CD_TIMES_ROMAN #2 - Fancy

Colors

Client Images

Server Images

  • All functions do nothing.