THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/03/2012 at 14:26, xxxxxxxx wrote:
hi,
i' am trying to create my first actual plugin. i have some minor experience with pyhton scripts and python xpresso nodes, so i am used to the SDK and the language itself. i am following the the python
example project Py-RoundedTube and the description files of c4d.olight.
i understood basicly the description system , but nevertheless i am pretty much stuck now. i cannot init the values properly which i set up in my description files. i have tried to use different ids, removed
description layout groups and more without any real success.
here is my project cropped to the relevant parts :
** Polylight.pyp**
import c4d
import math
import sys
import os
from c4d import plugins, utils, bitmaps, gui
PLUGIN_ID = 1028340
class Opolylight(plugins.ObjectData) :
def Init(self, op) :
self.InitAttr(op, c4d.Vector, [c4d.LIGHT_COLOR])
self.InitAttr(op, float, [c4d.LIGHT_BRIGHTNESS])
self.InitAttr(op, int, [c4d.LIGHT_TYPE])
self.InitAttr(op, int, [c4d.EMITDIRECTION])
self.InitAttr(op, int, [c4d.SAMPLINGMODE])
self.InitAttr(op, int, [c4d.MAXIMUMSAMPLES])
self.InitAttr(op, float, [c4d.ACCURACY])
self.InitAttr(op, bool, [c4d.ACCURATECOLOR])
self.InitAttr(op, bool, [c4d.ISAREALIGHT])
self.InitAttr(op, bool, [c4d.SEENBYGI])
self.InitAttr(op, bool, [c4d.SEENBYBYCAMERA])
self.InitAttr(op, bool, [c4d.SEENBYBYREFLECTIONS])
self.InitAttr(op, bool, [c4d.SEENBYBYREFRACTIONS])
self.InitAttr(op, int, [c4d.DISPLAYMODE])
op[c4d.LIGHT_COLOR] = c4d.Vector(1.0,1.0,1.0)
op[c4d.LIGHT_BRIGHTNESS] = 1.0
op[c4d.LIGHT_TYPE] = 1
op[c4d.EMITDIRECTION] = 2
op[c4d.SAMPLINGMODE] = 2
op[c4d.MAXIMUMSAMPLES] = 128
op[c4d.SAMPLINGMODE] = 0
op[c4d.ACCURACY] = 0.65
op[c4d.ACCURATECOLOR] = False
op[c4d.ISAREALIGHT] = True
op[c4d.SEENBYGI] = True
op[c4d.SEENBYBYCAMERA] = True
op[c4d.SEENBYBYREFLECTIONS] = True
op[c4d.SEENBYBYREFRACTIONS] = True
op[c4d.DISPLAYMODE] = 2
return True
def Draw(self, op, type, bd, bh) :
return c4d.DRAWRESULT_OK
def GetVirtualObjects(self, op, hierarchyhelp) :
dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
if dirty is False: return op.GetCache(hierarchyhelp)
return c4d.BaseObject(c4d.Ocube)
if __name__ == "__main__":
path, file = os.path.split(__file__)
icon = bitmaps.BaseBitmap()
icon.InitWith(os.path.join(path, "res", "polylight.tif"))
plugins.RegisterObjectPlugin(id = PLUGIN_ID,
str = "Polylight",
g = Opolylight,
description = "Opolylight",
icon = icon,
info = c4d.OBJECT_GENERATOR)
Opolylight.res (i know the layout is a bit heavy , but i suspected some formating errors here, so
i formated it in this super safe way)
CONTAINER Opolylight
{
NAME Opolylight;
INCLUDE Obase;
HIDE ID_BASEOBJECT_USECOLOR;
HIDE ID_BASEOBJECT_COLOR;
GROUP GENERAL_GRP
{
DEFAULT 1;
COLOR LIGHT_COLOR {OPEN;}
REAL LIGHT_BRIGHTNESS { UNIT PERCENT; MIN 0; MAX 1000000.0; MINSLIDER 0.0; MAXSLIDER 1000.0; STEP 5; CUSTOMGUI REALSLIDER; }
LONG LIGHT_TYPE
{
CYCLE
{
LIGHT_TYPE_DISC;
LIGHT_TYPE_PLANE;
-1;
LIGHT_TYPE_CUBE;
LIGHT_TYPE_CYLINDER;
LIGHT_TYPE_SPHERE;
-1;
LIGHT_TYPE_OBJECT;
}
}
LONG EMITDIRECTION
{
CYCLE
{
EMITDIRECTION_FRONT;
EMITDIRECTION_BACK;
EMITDIRECTION_BOTH;
}
}
SEPARATOR { LINE; }
LONG SAMPLINGMODE
{
CYCLE
{
SAMPLINGMODE_NORMAL;
SAMPLINGMODE_OVERSAMPLING;
SAMPLINGMODE_QMC;
SAMPLINGMODE_PERPIXELQMC;
}
}
LONG MAXIMUMSAMPLES { MIN 16; MAX 16384; }
REAL ACCURACY { PARENTID MAXIMUMSAMPLES; UNIT PERCENT; MIN 0.0; MAX 100.0; }
BOOL ACCURATECOLOR {}
BOOL ISAREALIGHT {}
SEPARATOR { LINE; }
BOOL SEENBYGI {}
BOOL SEENBYCAMERA {}
BOOL SEENBYREFLECTIONS {}
BOOL SEENBYREFRACTIONS {}
SEPARATOR { LINE; }
LONG DISPLAYMODE
{
CYCLE
{
DISPLAYMODE_ICON;
DISPLAYMODE_ISOPARMS;
DISPLAYMODE_FULL;
}
}
}
}
** Opolylight.h**
#ifndef _OPOLYLIGHT_H_
#define _OPOLYLIGHT_H_
// MaxID = 1107
enum
{
Opolylight = 10000 ,
GENERAL_GRP ,
LIGHT_COLOR = 1001,
LIGHT_BRIGHTNESS = 1002 ,
LIGHT_TYPE = 1003 ,
LIGHT_TYPE_DISC = 0 ,
LIGHT_TYPE_PLANE = 1 ,
LIGHT_TYPE_CUBE = 2 ,
LIGHT_TYPE_CYLINDER = 3 ,
LIGHT_TYPE_SPHERE = 4 ,
LIGHT_TYPE_OBJECT = 5 ,
EMITDIRECTION = 1004 ,
EMITDIRECTION_FRONT = 0 ,
EMITDIRECTION_BACK = 1 ,
EMITDIRECTION_BOTH = 2 ,
SAMPLINGMODE = 1005 ,
SAMPLINGMODE_NORMAL = 0 ,
SAMPLINGMODE_OVERSAMPLING = 1 ,
SAMPLINGMODE_QMC = 2 ,
SAMPLINGMODE_PERPIXELQMC = 3 ,
MAXIMUMSAMPLES = 1006 ,
ACCURACY = 1007 ,
ACCURATECOLOR = 1008 ,
ISAREALIGHT = 1009 ,
SEENBYGI = 1010 ,
SEENBYCAMERA = 1011 ,
SEENBYREFLECTIONS = 1012 ,
SEENBYREFRACTIONS = 1013 ,
DISPLAYMODE = 1014 ,
DISPLAYMODE_ICON = 0 ,
DISPLAYMODE_ISOPARMS = 1 ,
DISPLAYMODE_FULL = 2 ,
};
#endif
and there is also a Opolylight.str file of course.
when i execute the plugin the following things happen :
- the console throws AttributeError: 'module' object has no attribute 'SEENBYBYCAMERA'
- when i toggle comment SEENBYCAMERA and SEENBYREFRACTIONS the console doesn't throw any errors, but SOME initalized values aren't displayed correct. however they seem to be correct internally, because draging the values into the console returns the correct values.
- at this point - changing the id of LIGHT_COLOR from 1001 to 1000 will break the the correct init of the color. 1001 - color is white, 1000 color is black.
where is my mistake ? i could write much more, spent quite some time with this, but i think this
won't help aynone. i hope somone can enlighten me
cheers,
ferdinand
_
_