Can I load an environment file via the SDK/RDK?

Hi,

I had a look to the RDK sample concerning environment (RDK Current Environment with C/C++). This example shows in my understanding, how to create another environment and make another environment active.

But is there any possibility to load an environment file (e.g. from Rhino’s Render content) via the SDK? In my case I want to load and activate a specific environment file for reflection when I change to a PlugIn specific display mode.

Thanks

You can load the environment file as string in memory, then use CRhRdkContent::FromXMLStream to create the environment in memory. Then follow the sample further to set as reflection environment.

See also RhRdkLoadContentFromFile

OK, thanks! Will try that.

It works, many thanks!

Just another question concerning this topic: If I import a new environment,how can I find out if this special env is already in the document?

I tried it with comparing UUIDs, but it looks every add will create a new UUID (understandable).

Then I was looking to the function

virtual void IRhRdkCurrentEnvironment::CopyFrom ( const IRhRdkCurrentEnvironment & ce )

to replace the current envronment by my imported one. But I do not know, how to get a IRhRdkCurrentEnvironment from my imported CRhRdkEnvironment

OK, it looks as if something like this may help to identify a previously loaded render content:

const CRhRdkContent *pExistingContent = Doc->Contents().FindSimilar(LoadedEnvironment);

if (pExistingContent)
RhinoApp().Print(L"Environment already loaded previously\n");

Peter

Use the RenderCRC to determine if a render content is functionally the same.

Andy

Yup. FindSimilar will also compare the names.

Andy

Oh - and I missed one of your questions…

You get IRhRdkCurrentEnvironment from CRhinoDoc::CurrentEnvironment