60001918 I would like returned segments of method GetModel2dProjection to know from which entity they come from

Article 60001918
Type Wish
Product Engine
Date Added 2/22/2013 12:00:00 AM
Fixed (3/20/2013 12:00:00 AM)
Submitted by Giovanni Sava

Summary

I would like returned segments of method GetModel2dProjection to know from which entity they come from

Solution

In 6025, a new property/object, is added to the linesegment named customObj, that can be used in order to get the entity where this linesegment is produced from. See the code below and the remarks :

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)
{     
     vdLine ent = new vdLine(doc);
     vdFigure ownfig = null;
     RenderFormats.
PrimitiveRender3d.Primitive primitive = line.customObj as
                    RenderFormats.
PrimitiveRender3d.Primitive; // the primitive object that the line segment came from
     if (primitive != null) ownfig = primitive.TopItemDrawOwner as vdFigure; //get the vdFigure of this primitive object
     if (ownfig != null) ent.MatchProperties(ownfig, doc); // in order to set (match properties) the
                    // layer, color, linetype etc to the vdLine that will be added to the document
     ent.StartPoint = line.StartPoint;// set start point
     ent.EndPoint = line.EndPoint;// and end point
     layout.Entities.AddItem(ent); // add this vdLine to the document
}

Send comments on this topic.