The Eplan.EplApi.HEServices namespace provides the DrawingService class that contains functionality for outputting objects (WindowMacros, SymbolVariants, Placements, or Pages) on a window or control.
Displaying the preview takes two steps:
The first step is to create a so-called display list using the CreateDisplayList function. This actually processes the data into a list of graphical primitives that can be drawn. Depending on what kind of data you want to show, this function will take some time. For example, if you want to create a preview of a macro, CreateDisplayList loads the macro file, analyzes it and creates the items to display. You need to call this function just once for a given preview.
The second step actually shows the preview (the created display list) on a window. It takes a System.Windows.Forms.PaintEventArgs object as parameter, which is provided by any control in the Paint callback.
The DrawingService class also provides the possibility to influence the appearance of the preview in many ways, such as zooming and changing the background color.
The following example creates a preview of a macro. The first code snippet shows the creation of the display list:
The next piece of source code shows drawing the display list in the Paint method of a picture box:
To draw more complex images, it may be necessary to set the resolution and a viewport of the drawn image.
A viewport is a polygon that represents a part of a page that will be rendered:
This can be done using the SetViewport method. The coordinates should be passed in the graphical coordinate system.
If the given dimensions are not proportional to the drawing area, they are automatically adjusted to keep the aspect ratio:
In case of 3D drawings, it is also necessary to set the image size, otherwise its quality may be worse than in the EPLAN GED: