Get all Properties and update [SOLVED]



  • On 11/03/2016 at 16:31, xxxxxxxx wrote:

    I'm trying to create a tag plugin that accesses all properties of an object, list them in the plugin interface, and alter their values with various code multipliers.  I'm able to get the property types, but am unable to update an object property.  Here is what I have so far:

      
    for bc, paramid, groupid in description:                 # Iterate over the parameters of the description
        if bc[c4d.DESC_NAME] and bc[c4d.DESC_IDENT] and prop == True:
            theType = bc[c4d.DESC_IDENT]
            theType = str(theType)
            type2 = "c4d." + str(theType)
            doc.SendInfo(c4d.MSG_DOCUMENTINFO_TYPE_LOAD, c4d.FORMAT_C4DIMPORT, "", None, False)
            if bc[c4d.DESC_NAME] == "Size":
                print op[c4d.PRIM_CUBE_LEN]
                print type2
                print op[type2]
    

    The output with the tag on a default cube gives me:
    Vector(200, 200, 200)
    c4d.PRIM_CUBE_LEN
    IndexError: Invalid key type.



  • On 14/03/2016 at 02:37, xxxxxxxx wrote:

    Hello,

    in your code you store a string in your "type2" variable. Then you use that "type2" variable to access a parameter with "op[type2]". That makes no sense.

    GetParameter() or SetParameter(). This means that the ID of the parameter is not defined as a string but as a DescID object. While in many cases it is enough to just use the parameter ID integer value, in some cases a full DescID object has to be used.

    You are already looping through the description. While doing so you get the needed parameter ID with "paramid".

    Best wishes,
    Sebastian



  • On 15/03/2016 at 13:42, xxxxxxxx wrote:

    Thanks for the tip Sebastian.  
    Using paramID, and some detective work in this forum, I was finally able to get what I wanted.

    for bc, paramID, groupid in description:                 # Iterate over the parameters of the description
        if bc[c4d.DESC_NAME] and bc[c4d.DESC_IDENT] and prop == True:
            if bc[c4d.DESC_NAME] == "Size":
    id = paramID[0].id print op[id]
    

    This code gives me:
    Vector(200, 200, 200)


Log in to reply