Previous Thread  Next Thread

chat icon FloatVectorProperty

kollmanj

Posted: Sat Jan 26, 2013 7:37 pm
Joined: 26 Jan 2013
Posts: 3
I can't figure out how to use: FloatVectorProperty


Code:
    blocation = FloatVectorProperty(name="Becon Location",
        description="Becon Location",
        default=(0.0, 0.0, 0.0),
        min=(0.0,0.0,0.0),
        max=(100.0,100.0,100.0),
        step=3,
        precision=2,
        options={'ANIMATABLE'},
        subtype='TRANSLATION',
        size=3,
        update=None,
        get=None,
        set=None

 ....

my_z = blocation[2]


ERROR:
IndexError: tuple index out of range


How do I get the values entered by the user?


Thanks:
Razz
Reply with quote


CoDEmanX

Posted: Sun Jan 27, 2013 12:30 am
Joined: 05 Apr 2009
Posts: 894
you need to use an instance of a property, not the property definition.

It basically means, that (inside the same class) you need to access the property like
Code:
self.blocation


or if it's defined on "global level" like

Code:
bpy.types.Scene.blocation = ...

then you can access the currently relevant instance like
Code:
bpy.context.scene.blocation

_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


kollmanj

Posted: Sun Jan 27, 2013 1:26 am
Joined: 26 Jan 2013
Posts: 3
Here is the code:

Code:
print(self.blocation)


Here is the output:

(<built-in function FloatVectorProperty>, {'name': 'Becon Location', 'step': 3,
'set': None, 'options': {'ANIMATABLE'}, 'default': (0.0, 0.0, 0.0), 'description
': 'Becon Location', 'precision': 2, 'size': 3, 'max': (100.0, 100.0, 100.0), 'g
et': None, 'subtype': 'TRANSLATION', 'min': (0.0, 0.0, 0.0), 'update': None})

what do I do with that?

Thanks, for the reply but I'm still confused I must be missing something. Embarassed
Reply with quote


kollmanj

Posted: Sun Jan 27, 2013 4:05 am
Joined: 26 Jan 2013
Posts: 3
I think I'll just go with FloatProperty because I can't get this vectorproperty to work. But I thought I'd post this just to see if anyone can enlighten me. I'm going to list some code. The stuff related to FloatProperty works but the stuff related to FloatVectorProperty does not. Maybe someone can explain this mess, maybe not. Sad

Code:
    room_width =  FloatProperty(name="Room Width",
        description="Room Width",
        min=1.0,
        max=10,
        default=3)

    location = FloatVectorProperty(name="Receiver Location",
        description="Receiver Location",
        default=(0.0, 0.0, 0.0),
        min=(0.0,0.0,0.0),
        max=(100.0,100.0,100.0),
        step=3,
        precision=2,
        options={'ANIMATABLE'},
        subtype='NONE',
        size=3,
        update=None,
        get=None,
        set=None)
   
    blocation = FloatVectorProperty(name="Becon Location",
        description="Becon Location",
        default=(0.0, 0.0, 0.0),
        min=(0.0,0.0,0.0),
        max=(100.0,100.0,100.0),
        step=3,
        precision=2,
        options={'ANIMATABLE'},
        subtype='TRANSLATION',
        size=3,
        update=None,
        get=None,
        set=None)
       
    crap =    FloatVectorProperty(attr="myColorValue", min=0, max=1, default=0, name="myColor", description="my cool color value i can use for anything i like", subtype="COLOR")

    def draw(self, context):
        layout = self.layout
        box = layout.box()
        box.prop(self, 'room_length')
        box.prop(self, 'room_width')
        box.prop(self, 'location')
        box.prop(self, 'blocation')
        box = layout.box()
        layout.prop(context.material, "myColorValue")
Reply with quote


CoDEmanX

Posted: Sun Jan 27, 2013 9:45 pm
Joined: 05 Apr 2009
Posts: 894
one usually gets something like:

<built-in function FloatVectorProperty>

if one tries to add a property to an unsupported type (non-ID/bone/posebone type)

or if one accesses the property wrong (the variable, instead of the property instance)
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group