60000208 Setting the LineType Penstyle to Render

Article 60000208
Type HowTo
Product Engine
Date Added 7/26/2007 12:00:00 AM
Fixed (7/26/2007 12:00:00 AM)
Submitted by Florian Rappel

Summary

How can I change the linetype (solid, dashdot, etc.) for a render object? I know that the vdLineType is selectable in the Vdraw.BaseControl.ActiveDocument.LineTypes, but I can't find a similar collection for render line types.

Solution

In an empty project add a button that calls the cmdLine "user" and a VDScrollable control. Add the OnActionDraw event handler and in the ActiveDocument_OnActionDraw use a code like :

void ActiveDocument_OnActionDraw(object sender, object action, bool isHideMode, ref bool cancel)
{
    if (!(action is VectorDraw.Actions.ActionGetRefPoint)) return;
    VectorDraw.Actions.BaseAction act = action as VectorDraw.Actions.BaseAction;
    VectorDraw.Geometry.gPoint refpoint = act.ReferencePoint;
    VectorDraw.Geometry.gPoint currentpoint = act.OrthoPoint;

    // Draw the circle using vdCircle object 

    VectorDraw.Professional.vdFigures.vdCircle circle = new VectorDraw.Professional.vdFigures.vdCircle();
    circle.SetUnRegisterDocument(vdSC.BaseControl.ActiveDocument);
    circle.setDocumentDefaults();
    circle.LineType = vdSC.BaseControl.ActiveDocument.LineTypes.DPIDashDotDot;
// The Linetype here
    circle.Center = VectorDraw.Geometry.gPoint.MidPoint(refpoint, currentpoint);
    circle.Radius = circle.Center.Distance3D(refpoint);
    circle.Draw(act.Render);

    // OR you can use the Render.Draw....

    act.Render.PushPenstyle(Color.Red, 0.1d, vdSC.BaseControl.ActiveDocument.LineTypes.FindName("CENTER").GetgrLineType());
    act.Render.DrawLine(sender, new VectorDraw.Geometry.gPoint(0, 0, 0), currentpoint);
    act.Render.PopPenstyle();
// THIS IS NECESSARY after every push
}

Send comments on this topic.