On 05/06/2016 at 04:43, xxxxxxxx wrote:
Hello,
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.
My code:
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.
greetings,
neon