Why use InitAttr ?



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

    On 31/07/2012 at 18:35, xxxxxxxx wrote:

    To initialize the elements of the description of my tag, should I use something like:

    def Init(self,node) :
         data = node.GetDataInstance()
         data.SetData(SD_ON,True)

    or something like:
    [COLOR=blue]
    def Init(self, node) :
        self.InitAttr(host=node, type=bool, desc=[SD_ON])
        node[SD_ON] = True

    What is the difference?



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

    On 31/07/2012 at 19:50, xxxxxxxx wrote:

    You only need self.InitAttr() for initializing GUI elements,
    then setting the values to the GUI's.
    Regular values you set directly using your IDs.

    Such as:

      
         def Init(self, pconnector) :   
              pconnector[DIRTYSUM]               = c4d.BaseContainer()   
              # Source Settings   
              pconnector[c4d.PC_SHIDE]          = True   
              pconnector[c4d.PC_MODE_ALL]          = 0   
              pconnector[c4d.PC_AMOUNT]          = 1.0   
              pconnector[c4d.PC_CONNECT]          = 0   
              # Point Settings   
              pconnector[c4d.PC_STARTPOINT]            = 1.0   
              pconnector[c4d.PC_ENDPOINT]             = 100.0   
              pconnector[c4d.PC_OFFSETPOINT]           = 0.0   
              pconnector[c4d.PC_DIRECTION]             = 0   
              pconnector[c4d.PC_POINTSTEP]             = 1.0   
              pconnector[c4d.PC_CONNECTSTEP]           = 1.0   
              pconnector[c4d.PC_MAXPOINTDIF]           = 1000.0   
              pconnector[c4d.PC_RANDOM]          = 0.0   
              # Spline Settings   
              pconnector[c4d.PC_MAKESPLINE]          = True   
              pconnector[c4d.PC_SPLINE_MIN]          = 0.0   
              pconnector[c4d.PC_SPLINE_MAX]          = 1000.0   
              pconnector[c4d.PC_SEGMENT_START]     = 0.0   
              pconnector[c4d.PC_SEGMENT_END]          = 1.0   
              pconnector[c4d.PC_DISTANCE_GROW]     = 0   
              pconnector[c4d.PC_DISTANCE_SENSE]     = 0.8   
              pconnector[c4d.PC_SPLINE_SUB]          = 0   
              #TP life   
              self.InitAttr(pconnector, c4d.SplineData, [c4d.PC_TPCURVE])   
              icurve = pconnector[c4d.PC_TPCURVE]   
              icurve.SetRange(0.0, 1.0, 0.01, 0.0, 1.0, 0.01)   
              icurve.InsertKnot(1,1,0)   
              icurve.InsertKnot(0,1,0)   
              pconnector[c4d.PC_TPCURVE] = icurve   
              # General   
              pconnector[c4d.PC_SPACE]          = 0   
              pconnector[c4d.PC_CACHE]          = False   
              pconnector[c4d.PC_INFO]               = 'Ready'   
              #etc   
              return True   
    

    Cheers
    Lennart



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

    On 31/07/2012 at 20:00, xxxxxxxx wrote:

    I have been initializing the values of the GUI elements of the description in the Init method, using:

    def Init(self,node) :
         data = node.GetDataInstance()
         data.SetData(SD_ON,True)
         data.SetData(SD_USE_CHILDREN,False)
         data.SetData(SD_NO_INTERPOLATE,False)
         data.SetData(SD_INSTANCES,False)
         data.SetData(SD_DRAW_SPHERES,True)
         return True

    Is this incorrect?



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

    On 31/07/2012 at 20:17, xxxxxxxx wrote:

    It's incorrect as we are not recommended to use the basecontainer (.GetDataInstance()).
    What I mean by GUI elements is things like the Spline GUI, it is just the
    "background" that holds no values. It needs to get the values set as you can see
    in my example before.

    Your init should/could look:

      
    def Init(self,node) :   
         node[c4d.SD_ON] = True   
         node[c4d.SD_USE_CHILDREN] = False   
         node[c4d.SD_NO_INTERPOLATE] = False   
         node[c4d.SD_INSTANCES] = False   
         node[c4d.SD_DRAW_SPHERES] = True   
         return True   
    

    ..given the ID's are in your res/str/.h files

    Cheers
    Lennart



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

    On 31/07/2012 at 20:18, xxxxxxxx wrote:

    Much simpler :-)
    Thank you, Lennart.


Log in to reply