[C++] how to find Perspective view (=>CRhinoView*)

Hi,

I need to get CRhinoView* of the Perpective view in order to change its display mode. Is there another way to do this without comparing the view name, so that the view is found with any installed language pack, not only with the English version?

That means, any alternative to this code?

CRhinoView* CUtilityFunc::GetPerspectiveView()
{
	ON_SimpleArray<CRhinoView*> view_list;
	::RhinoApp().ActiveDoc()->GetViewList (view_list);
	CRhinoView* view = view_list[0];
        ON_wString name;

	for (int i = 0; i < view_list.Count(); i++)
	{
		view = view_list[i];
		name = view->Viewport().Name();
		if (name.CompareNoCase (L"Perspective") == 0)			
		      break;
	}
	return view;
}

Hi @AncaG,

How about something like this?

CRhinoView* CUtilityFunc::GetPerspectiveView(CRhinoDoc& doc)
{
  ON_SimpleArray<CRhinoView*> view_list(4);
  doc.GetViewList(view_list, true, false);
  for (int i = 0; i < view_list.Count(); i++)
  {
    CRhinoView* pView = view_list[i];
    if (pView && pView->ActiveViewport().VP().IsPerspectiveProjection())
      return pView;
  }
  return nullptr;
}

– Dale

Thanks for the answer! It worked as expected.