Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    too stupid for description system :)

    Scheduled Pinned Locked Moved PYTHON Development
    14 Posts 0 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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 :

      1. the console throws  AttributeError: 'module' object has no attribute 'SEENBYBYCAMERA'
      2. 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.
      3. 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
      _
      _

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 12/03/2012 at 14:31, xxxxxxxx wrote:

        here are the files :

        https://docs.google.com/file/d/0ByJvCHzEwMdlVUc2N2YzSEhTWU9nenZ2UmRlMUhGUQ/edit

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 12/03/2012 at 14:58, xxxxxxxx wrote:

          Se if doing the init on the DataInstance helps.
          (What I do in an object plugin of mine.)

            
          class Opolylight(plugins.ObjectData) :   
                  
               def Init(self, op) :   
                    data = op.GetDataInstance()   
                    data.SetVector(c4d.LIGHT_COLOR,c4d.Vector(1.0,1.0,1.0)   
                    data.SetFloat(c4d.LIGHT_BRIGHTNESS,1.0)   
                    data.SetLong(c4d.LIGHT_TYPE,1)   
                    etc…   
                    return True   
            
               def Draw()   
               def GetVirtualObjects()   
          

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 12/03/2012 at 20:08, xxxxxxxx wrote:

            hi,

            thank for your reply, the console still returns:

            > AttributeError: 'module' object has no attribute 'SEENBYBYCAMERA'

            for :

            	def Init(self, op) :
            		data = op.GetDataInstance()
              
            		data.SetVector(c4d.LIGHT_COLOR,c4d.Vector(1.0,1.0,1.0))
            		data.SetReal(c4d.LIGHT_BRIGHTNESS,1.0)
            		data.SetLong(c4d.LIGHT_TYPE,1)
            		data.SetLong(c4d.EMITDIRECTION,2)
            		data.SetLong(c4d.SAMPLINGMODE,2)
            		data.SetLong(c4d.MAXIMUMSAMPLES,128)
            		data.SetReal(c4d.ACCURACY,0.65)
            		data.SetBool(c4d.ACCURATECOLOR, True)
            		data.SetBool(c4d.ISAREALIGHT, True)
            		data.SetBool(c4d.SEENBYGI, True)
            		data.SetBool(c4d.SEENBYBYCAMERA, True)
            		data.SetBool(c4d.SEENBYBYREFLECTIONS, True)
            		data.SetBool(c4d.SEENBYBYREFRACTIONS, True)
            		data.SetLong(c4d.DISPLAYMODE,2)
            		return True
            

            gnahgnahgnah ...

            edit : it is in this semi-working state like it is when i remove :

            	op[c4d.SEENBYBYREFLECTIONS] = True
            
            	op[c4d.SEENBYBYREFRACTIONS] = True
            

            1-4 correct, 5-7 wrong, 8-9 correct, 10-11 wrong, 12 correct, 13-14 wrong ... oO

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 12/03/2012 at 20:27, xxxxxxxx wrote:

              "SEENBYBYCAMERA" ? 🙂

              Cheers
              Lennart

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 12/03/2012 at 20:33, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                "SEENBYBYCAMERA" ? 🙂

                Cheers
                Lennart

                not sure what you want to say ? SEENBYCAMERA like the boolean in the compositing tag.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 12/03/2012 at 20:39, xxxxxxxx wrote:

                  seenBYBYcamera, I guess it easy to get "word blind".
                  Check the spelling:)

                  Cheers
                  Lennart

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 12/03/2012 at 20:49, xxxxxxxx wrote:

                    weeh,

                    its far too late for me 🙂 however, after correcting the typo the console returns :

                    _ AttributeError: 'module' object has no attribute 'SEENBYREFLECTIONS' _
                    _
                    _
                    the funny thing is, c4d.SEENBYREFLECTIONS is true and its checkbox is checked. if there is a god, its a cruel one 😞

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 12/03/2012 at 21:52, xxxxxxxx wrote:

                      Perhaps you are having trouble because you changed your descriptions. But didn't delete your coffeesymbolcache file?

                      That one tends to burn everyone at least once.

                      -ScottA

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 13/03/2012 at 05:19, xxxxxxxx wrote:

                        To me,

                          
                            self.InitAttr(op, bool, [c4d.SEENBYBYREFLECTIONS])   
                            self.InitAttr(op, bool, [c4d.SEENBYBYREFRACTIONS])   
                        

                        looks spelt wrong "..BYBY.." but also as Scott mentioned,
                        the coffesymbolcache file might need to be deleted for
                        Cinema to update it.

                        Cheers
                        Lennart

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 13/03/2012 at 09:22, xxxxxxxx wrote:

                          that did the trick 🙂 cannot express it in words how gratefull i am for your help and how angry i am, that neither the c++ sdk nor the python sdk mention this with a word (at least at their description sections).

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 13/03/2012 at 09:37, xxxxxxxx wrote:

                            The file is located here on a Windows OS:C:\YOUR username here\user\AppData\Roaming\MAXON\YOUR c4d version here\prefs\coffeesymbolcache

                            You didn't specify Mac or PC. Or what version you're using.
                            There are a great many differences between R12 & R13. So please always provide that info in your posts.

                            BTW: I don't know if you know this or not. But the file link you posted says I need special permission from you to download it. That's not going to get you a lot of help either. 😉

                            -ScottA

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 13/03/2012 at 09:54, xxxxxxxx wrote:

                              sorry about the google docs. but the problem is solved i found the file and it works, again thanks for your help 🙂

                              1 Reply Last reply Reply Quote 0
                              • H Offline
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 13/03/2012 at 10:14, xxxxxxxx wrote:

                                Lol.

                                That stupid cache file thing is sort of a rite of passage that all python plugin newbies have to go through.
                                It's sort of like a fraternity hazing...Everyone has to go through it at least once to be in the club.😂

                                -ScottA

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post