Material not rendering in PV [SOLVED]
On 05/06/2016 at 04:43, xxxxxxxx wrote:
I have a litle problem with an Object Plugin.
In my plugin I import a material from an c4d file in the res folder (its a more complex material,so I don't create it in my plugin)
I have searched and read some threads about this but it just doesn't seem to work for me.
import os import c4d import random from c4d import plugins, bitmaps, utils, gui, storage PLUGIN_ID = 1037525 class olightroom(plugins.ObjectData) : def __init__(self) : self.SetOptimizeCache(False) doc = c4d.documents.GetActiveDocument() if doc.SearchMaterial("MITA_HDRI") == None: dir, f = os.path.split(__file__) path = os.path.join(dir, "res/mats", "hdri.c4d") c4d.documents.MergeDocument(doc, path , c4d.SCENEFILTER_0|c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS|c4d.SCENEFILTER_MERGESCENE) self.hdri_material = doc.SearchMaterial("MITA_HDRI") self.textureTag = c4d.TextureTag() self.textureTag.SetMaterial(self.hdri_material) self.textureTag.Message(c4d.MSG_UPDATE) self.hdri_material.ChangeNBit(c4d.NBIT_OHIDE, c4d.NBITCONTROL_SET) def GetVirtualObjects(self, op, hh) : doc = c4d.documents.GetActiveDocument() main_obj = c4d.BaseObject(c4d.Onull) hdri_object = c4d.BaseObject(c4d.Osky) hdri_object.InsertTag(self.textureTag, None) hdri_object.InsertUnder(main_obj) hdri_object.ChangeNBit(c4d.NBIT_OHIDE, c4d.NBITCONTROL_SET) return main_obj if __name__ == "__main__": path, fn = os.path.split(__file__) bmp = bitmaps.BaseBitmap() bmp.InitWith(os.path.join(path, "res", "icon.tif")) plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="Mita's Lightroom 1.0", g=olightroom, description="olightroom", icon=bmp, info=c4d.OBJECT_GENERATOR)
The funny thing is, that it works in the opengl view.
Hopefully someone can help me.
On 10/06/2016 at 09:10, xxxxxxxx wrote:
Hasn't got anyone an idea?
Or was I just not clear enough?
On 10/06/2016 at 11:07, xxxxxxxx wrote:
__init__() is the wrong place to do this, and GetActiveDocument() is
not always the right document to do this with.
Also, consider what happens when the material is deleted by the user.
Maybe that helps,
On 13/06/2016 at 02:50, xxxxxxxx wrote:
a NodeData based plugin like ObjectData could be used in any context or situation (background rendering, team render client, etc.). So it is never save to call GetActiveDocument() from a NodeData based plugin.
If you want to modify or interact with the scene that will receive the object instance when it is created from the GUI you can catch the message MSG_MENUPREPARE. This message is sent to the object before it is inserted into the BaseDocument. But the given data is a reference to the target BaseDocument.
See the DoubleCircle example.
On 24/06/2016 at 06:16, xxxxxxxx wrote:
was you question answered?
On 24/06/2016 at 11:05, xxxxxxxx wrote:
yes my question was answered!
I actually did reply but I think I missed the post reply button and closed the Window to early, sry my bad.
Thanks again for all the Information.