FloatVectorProperty

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

kollmanj
Posts: 3
Joined: Sat Jan 26, 2013 7:30 pm
Location: USA

FloatVectorProperty

Postby kollmanj » Sat Jan 26, 2013 7:37 pm

I can't figure out how to use: FloatVectorProperty


Code: Select all

    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:
:P

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Sun Jan 27, 2013 12:30 am

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: Select all

self.blocation


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

Code: Select all

bpy.types.Scene.blocation = ...

then you can access the currently relevant instance like

Code: Select all

bpy.context.scene.blocation
I'm sitting, waiting, wishing, building Blender in superstition...

kollmanj
Posts: 3
Joined: Sat Jan 26, 2013 7:30 pm
Location: USA

still confused

Postby kollmanj » Sun Jan 27, 2013 1:26 am

Here is the code:

Code: Select all

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. :oops:

kollmanj
Posts: 3
Joined: Sat Jan 26, 2013 7:30 pm
Location: USA

Postby kollmanj » Sun Jan 27, 2013 4:05 am

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. :(

Code: Select all

    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")

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Sun Jan 27, 2013 9:45 pm

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...


Return to “Coding Blender”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest