I would like to programatically perform the action of the “Place” named view button:
doing something like
doc.NamedViews[0].Viewport.SetCameraLocation(…)
has no effect on the document. Why? What is the correct way to do this?
I would like to programatically perform the action of the “Place” named view button:
doing something like
doc.NamedViews[0].Viewport.SetCameraLocation(…)
has no effect on the document. Why? What is the correct way to do this?
Did you try this example?
Yes. I got it working but it required a very strange approach - I had to restore the named view, modify the viewport camera, delete the named view and recreate it from the viewport. Is this the way to go?
Not sure but I think so. Because in Rhino it basically works the same. You can change the camera of a named view but this will not overwrite the named view automatically. What I don’t get from your comment is why you would first need to restore the named view.
I have to restore, because the following code has no effect:
ViewInfo vi = doc.NamedViews[0];
RhinoApp.WriteLine($"Moved {vi.Name}");
//doc.NamedViews.Delete(vi.Name);
vi.Viewport.SetCameraLocation(Point3d.Origin);
doc.NamedViews.Add(vi);
No matter if the delete line exists or not, the named view does not change.