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.
Answering my own question, just in case someone has the same question.
public Guid Draw(Curve crv)
{
// set object attribute
var objctAttrbt = new Rhino.DocObjects.ObjectAttributes();
// set one of the detail views active
var pgVw = doc.Views.GetPageViews()[0];
var dtlVw = pgVw.GetDetailViews()[0];
dtlVw.IsActive = true;
// add geometry to the doc
var gid = doc.Objects.AddCurve(crv, objctAttrbt);
// deactivate the detail view
dtlVw.IsActive = false;
// refresh
doc.Views.Redraw();
// return output
return gid;
}
@menno , although the above works, I found it is resource intensive, especially in PCs (strangely it is much faster in Macs). Do you have any suggestions to do it without activating any of the model spaces? Thanks,