- Wed Feb 29, 2012 12:03 am
#353275
Thanks a billion...
I was working my way through the plugin code from the ApplyMaterial... methods. My quess was that the plugin does some initial steps to establish the scene and all. Just found out about the CurrentInstance beiing routed through today and already fixed that.
Right now the helpers are perfect for what I do and I'll definitely keep away from Init(). I hope to implement multilayer materials soon so this will get a little more complex... but wht
I wrote this little snippet in order to have the material previews update in the scen manager. Surely you will have a way less complex way to make it all work that I have not yet stumbled upon.
P.S.: going to see what the Grasshopper forum has to say about all this
I was working my way through the plugin code from the ApplyMaterial... methods. My quess was that the plugin does some initial steps to establish the scene and all. Just found out about the CurrentInstance beiing routed through today and already fixed that.
Right now the helpers are perfect for what I do and I'll definitely keep away from Init(). I hope to implement multilayer materials soon so this will get a little more complex... but wht

I wrote this little snippet in order to have the material previews update in the scen manager. Surely you will have a way less complex way to make it all work that I have not yet stumbled upon.
Code: Select all
P.S.: I see that there was some stray experimental code left in the MaterialList. ApplyMaterial is done by the MaterialBake component now. All the Rhino related stuff is passed to Grasshopper and I only provide the additional attribs. Once I found this trick, baking became a piece of cake.
private double SL;
protected void UpdatePreview(Material mxMat)
{
if (SL <= 0.0)
return;
mxMat.MaxPreviewSL = (uint)SL;
mxMat.PreviewScene = "emitter_02m";
Scene.EnableRaisingEvents = true;
Material.PFire.WaitForIdle();
Material.SelectedMaterial = mxMat;
mxMat.RefreshPreview(true);
while (Material.PFire.SceneDirty)
Material.PFire.WaitForIdle();
}

P.S.: going to see what the Grasshopper forum has to say about all this
