60000996 Export a drawing into simple lines as 2D and removing Hidden lines

Article 60000996
Type Wish
Product Engine
Version 6022
Date Added 11/6/2009 12:00:00 AM
Fixed (4/26/2012 12:00:00 AM)
Submitted by Kerry Francis

Summary

Export a 3D drawing in Hide mode as 2D objects

Solution

The following new methods was added in version 6023 : 

1. GetModel2dProjection of vdDocument object
It gets three parameters:

  • ViewOrigin gPoint : Its the Origin point (eye location) in World Coordinate System(WCS) of clip view plane.
  • VisibleDirection Vector : Visible view direction (eye direction) of clip view plane in World Coordinate System(WCS).
  • twistAngle Double : An angle in radians that represent the rotation of the scene around the direction in clockwise direction.

and  returns: A collection of line segments that represents the 2D projection of the clipping for all objects in the Model Layout of the passed document.

Code Example:

   //prompts the user for a new section clip
   //generates a 2d projection line segments and add them into a new layout
            doc.Prompt("section origin");
            gPoint origin = doc.ActionUtility.getUserPoint() as gPoint;
            doc.Prompt(null);
            if(origin == null) return;
            doc.Prompt("section view direction");
            gPoint dir = doc.ActionUtility.getUserRefPoint(origin) as gPoint;
            doc.Prompt(null);
            linesegments segs = doc.GetModel2dProjection(origin,new Vector(origin, dir),0.0);
            vdLayout layout = doc.LayOuts.Add("section_2d_projection");
            layout.Entities.RemoveAll();
            foreach (linesegment line in segs)
            {
                 layout.Entities.AddItem(new vdLine(doc, line.StartPoint, line.EndPoint));
            }

  
2. ExportToLines of vdPrint object

Exports the printable view area into a vdDocument object that contains single lines for all drawing objects.

Remarks:
    Viewports of layouts are not exported.
    3D views are exported as in Hide rendering mode.
    Exported lines are clipped inside the vdPrint's PrintWindow area.
    Exported lines are transformed relative to printer paper in millimeters with origin the Upper Left corner.
    All lines are added in the Model layout of the return document object and belongs to default Layer "0" with foreground color.
    Exporting lines of a printer view into a vdcl file can be also done by setting the PrinterName to an existing file with .vdcl extension.


Code Example:

	// create a block of the model printer and add it into a new layout with name "model view"
                vdDocument blockDocument = doc.Model.Printer.ExportToLines();
                vdBlock block = doc.Blocks.AddFromDocument("modelview", blockDocument, true);
                vdLayout layout_with_modelview = doc.LayOuts.Add("model view");
                vdInsert insert = new vdInsert(doc,block,new gPoint(0,0),0.0,1.0,1.0,1.0);
                layout_with_modelview.Entities.AddItem(insert);
                doc.ActiveLayOut = layout_with_modelview;
                doc.CommandAction.Zoom("e", null, null);

Send comments on this topic.