How to get the equivalent of model units from within PlugIn.CreatePreview

In my render plugin, I always need to know the model units, since it is a physically-based renderer, and requires to know the real sizes of things. However, in PlugIn.CreatePreview we have no document, just an environment, viewport, and lists of objects/lights.

So I am looking to be able to get the scale I need from here:


I am guessing I might get this value from RenderMaterial.DefaultPreviewSize, but the sdk says I don’t need to know the material for which I’m rendering a preview:

Maybe I can find out by looping the provided SceneObjects and finding one that matches CreatePreviewArgs.ContentTypeId, but besides this seeming quite a hack, there could be more than one that matches. And that is assuming that RenderMaterial.DefaultPreviewSize is really what I’m after, in the first place.

So I figure I must be missing something, and will appreciate any direction.

[edit: it occurs to me now, I target v6 and something more could have been added in the v7 sdk, I’ll take a look]

1 Like

I don’t recall anything being added to the v7 SDK to get this information.

Are you using the ChangeQueue mechanism to get the data for the preview scene?

Yes, for this I am using a ChangeQueue with ctor that takes CreatePreviewEventArgs, and passing it to the base ctor.

Right, at the very moment there is no way to get information about the model unit setting. Let me create a YT item for that so we can get it on the list.

RH-64647 Add a way to query model unit setting through ChangeQueue

add: note though that the size setting you highlighted in your OP is the amount of units. So you’d still need the document model unit setting.


Thanks. Whatever it takes to know the real size of objects will work great.