Looking for a way to use this enumeration to define a view but can’t find how it is used in RhinoView class.
Is there an way to determine view type, model space or page view?
Best steve
Looking for a way to use this enumeration to define a view but can’t find how it is used in RhinoView class.
Is there an way to determine view type, model space or page view?
Best steve
Hi Steve -
RhinoViewport.ViewportType
should get you this, if I understand.
-Pascal
Hi @slyon,
This also works:
private static bool IsPageView(RhinoView view)
{
return null != view && view is RhinoPageView;
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
foreach (var view in doc.Views)
{
if (IsPageView(view))
{
// todo...
}
}
return Result.Success;
}
– Dale
And this too:
var page_views = doc.Views.GetPageViews();
– Dale
Thanks, but the point was to distinguish between view types without needing a switch. If McNeil defines this in code it will be more robust on my end.
This was why I was point to the enum. Must be used somewhere but may not de exposed. If not switch it must be for me.
Cheers
Steve
Dale, Pascal:
Got it, don’t know why I missed this but turned out to be really simple to distinguish the view type. In ActiveView there is a GetType method that will return the base type of the active view object. Looking at that you can see the class that created the object when you use the Views.AddPageView method. The name property will give you one of these base classes by name:
RhinoPageView
RhinoView
switch (_doc.Views.ActiveView.GetType().Name)
{
case "RhinoView":
break;
case "RhinoPageView":
break;
default:
break;
}
From this you can determine if this view is in Model Space or a Page view.
Thanks again for all the help!
Best;
Steve
I would recommend Dale’s solution. It is more robust than comparing strings for underlying data types.
If you want to use the enum, you can use the following code
var viewtype = view.MainViewport.ViewportType;
Steve:
Excelent!
RhinoViewport mainViewport = _doc.Views.ActiveView.MainViewport;
RhinoViewport activeViewport = _doc.Views.ActiveView.ActiveViewport;
switch (activeViewport.ViewportType)
{
case ViewportType.StandardModelingViewport:
break;
case ViewportType.PageViewMainViewport:
break;
case ViewportType.DetailViewport:
break;
default:
break;
}
Just to let people know the code application.
Best;
Steve
Don’t use ActiveViewport. That could be a different viewport depending on if a detail is active or not.
Dale’s test to see if a view is a page view or not is really the best solution.
Steve, Noted.
Here is the context and please tell me if I am still barking up the wrong tree and code updates from McNeil may not be compatible.
In using this switch the only question I have to answer is if the current viewport I have clicked on is a Model viewport (Left, Right, Top …) or not. What is left is Page views (Page 1, Page 2, Trash Page …). So to answer the question I could do this:
switch (activeViewport.ViewportType)
{
case ViewportType.StandardModelingViewport:
break;
default:
break;
}
Later I am also asking the question:
switch (_doc.ModelSpaceAnnotationScalingEnabled)
{
case true:
break;
default:
break;
}
To complete the context. I am adding text to the different viewport types.
Just trying to be terse as I can using the API.
Thanks
Steve