How to get positions (x,y,z values) for the Named Views and the viewports (if it is present)?

Hi,
As the question says, is there any way of getting the co-ordinates of the named views or view ports in Rhino, if it is possible?

Hi @alexian007,

The term “named view” is a bit misleading, as we don’t really store views, proper. Rather, we store view projections. In C++, this is the ON_3dmView class.

What are you trying to do with named views?

– Dale

Hey @dale,
Thanks for clearing that up!

Yes, I am using the ON_3dmView class to store a reference to the namedview.

You see, I am trying to export the information about namedview, along with the meshes, materials, etc of the current Rhino Document to be used in another modeling software.

So I wanted to get the namedview and its position on the world, i.e where it resides (kinda like its vertices?).

Currently, I’ve got this far:

// Iterate through the named views in the document

	const ON_wString namedViewName;

	while (nullptr != (view_3dm = rhinoDocument.Properties().NamedView(namedViewIndex)))
	{
		//Get name for the NamedView:
		const char* currentNamedViewName = GetNameFromONwStr(view_3dm->m_name);
		::RhinoApp().Print("\n The named view's name is %ls!", currentNamedViewName);

		if (currentNamedViewName == nullptr)
		{
			std::string dummyNVName = "named_view_" + std::to_string(objectIndex);
			currentNamedViewName = dummyNVName.c_str();
		}

		// Get named view ID:
		const char* currentNViewUUID = GetUUIDFromONUUID(view_3dm->m_named_view_id);

		//Get camera location
		ON_3dPoint cameraLocation = view_3dm->m_vp.CameraLocation();
}

@dale, is this the correct way to proceed?
Thank you!

Hi @alexian007,

I’m not sure how to answer this. You code does iterate the named views. However, I’m not sure what good knowning what the location of the camera is without knowing where the camera-target is, or the camera up direction, or everything that it take to construct a view projection.

– Dale