0

Can't add new property

I can't seem to add a new property to a RVFileSource node in Python. I'm doing the following:

 

    file_source = rv.commands.addSourceVerbose([path])

    prop = file_source + '.myprop'

    print(prop)

    rv.commands.newProperty(prop, rv.commands.StringType, 1)

 

When I run this I get the following output

    sourceGroup000000_source.myprop

    Exception: Exception thrown while calling commands.newProperty -- exception: "in commands.newProperty: malformed property name", program exception

 

I get the same thing if I try to build a mu command and eval that instead. I guess the clue's in the exception, but I can't see at first glance how the property name is different from others?

 

Cheers,

 

Anders

2 comments

  • 0
    Avatar
    Anders Langlands

    ...aaaand as soon as I submit this I read the docs again and see that I explicitly need three parts to the property name. 

     

        file_source = rv.commands.addSourceVerbose([path])

        prop = file_source + '.my.prop'

        print(prop)

        rv.commands.newProperty(prop, rv.commands.StringType, 1)

        rv.commands.setStringProperty(prop, ['blahblah'], True)

     

    Incidentally, if I set the last parameter of setStringProperty() to False (or let it default), then I get an exception saying "number of values does not match property size", which was very confusing. Why is that?

  • 0
    Avatar
    Jon Morley

    Hi Anders,

    I am glad you were able to sort out your original issue. It is true that each property is nested in a component attached to a node.

    The reason you have to pass True for the third argument (allowResize) when setting a new property is because the property doesn't start out with a size and must be resized to fit whatever value you set. It might seem like you gave the property a size when you created it in the third argument to newProperty, however that argument is the depth of the property. If in your example you set it to 2 then you could set the actual value of the property to [("stringA","stringB")] in a list of tuple pairs. Does that make sense?

    Thanks,
    Jon

Please sign in to leave a comment.