Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4120

Add Geometry to doc

$
0
0

Hi all,

I am writing a C# component that adds curves to the rhino doc using AddCurve(curve, object attribute) method. This works quite well on the model spaces (Perspective, Top, Front, Right, etc) - whichever viewport is active, it creates the geometry at the same spot in the WorldXYZ space. However, if I run the code with the layout view active, it instead add the geometry in the layout.

There must be a way to let Rhino add the curve in model space even though the layout is set as an active view. Does anyone know how to do this?

public Guid Draw(Curve crv)
{
    // set object attribute
    var objctAttrbt = new Rhino.DocObjects.ObjectAttributes();
    objctAttrbt.DisplayOrder = 1;

    // add geometry to the doc
    var gid = doc.Objects.AddCurve(crv, objctAttrbt);

    // refresh
    doc.Views.Redraw();

    // return output
    return gid;
}

Just to better illustrate, the first picture below shows the result of the code - where I run the code in any of model space views, then set the layout view(paper) active to see the geometry in the proper position.

and this shows the result of the code ran in the layout view.

Any feedback will be much appreciated. Thanks,

W

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4120

Trending Articles