CD_DGN

CD - Canvas Draw

CD_DGN - 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. The filename must be inside double quotes (") if it has spaces. 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.78 pixels/mm" (96 DPI). 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 cdCanvasGetSize 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

  • Clear: does nothing.
  • Play: does nothing, returns CD_ERROR.

Coordinate System and Clipping

  • Clip: does nothing (no clipping function is supported), returns CD_CLIPOFF.
  • UpdateYAxis: does nothing. The axis orientation is the same as the CD library.
  • Transformation Matrix: not supported.

Primitives

  • Begin: if parameter CD_CLIP or CD_BEZIER are specified, does nothing.
  • cdChord: does nothing.

Attributes

  • BackOpacity: does nothing, returns CD_OPAQUE.
  • WriteMode: does nothing, returns CD_REPLACE.
  • InteriorStyle: does nothing.
  • FillMode: does nothing.
  • LineCap: does nothing.
  • LineJoin: does nothing.
  • Hatch: does nothing.
  • Stipple: does nothing.
  • Pattern: does nothing.
  • TextSize: returns a bounding box which is usually larger than the text (the computation is based on the widest character).
  • TextAlignment: uses cdTextSize, therefore is not precise.
  • Font: See the font mapping table for the equivalence used to map CD fonts into MicroStation fonts. Styles are not supported.
Font Mapping
CD Fonts MicroStation Font Index
CD_SYSTEM 0
CD_COURIER 1
CD_TIMES_ROMAN 2
CD_HELVETICA 3

Colors

Client Images

  • GetImageRGB: does nothing.
  • PutImageRGB: considering that the format supports only 256 colors, image quality is quite poor.
  • PutImageRGBA: alpha is ignored.
  • PutImageMap: considering that the format supports only 256 colors, image quality is quite poor.

Server Images

  • All functions do nothing.