1
$\begingroup$

What is the python code to make multiple float property like in the mapping node? enter image description here

$\endgroup$
5
$\begingroup$

Use a FloatVectorProperty and set its subtype to 'XYZ' or 'TRANSLATION'.

Currently other available subtypes of that property are: 'COLOR', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'COLOR_GAMMA', 'LAYER'.

enter image description here

Ripped from: How to create a custom UI?

import bpy

from bpy.props import (FloatVectorProperty,
                       PointerProperty
                       )

from bpy.types import (Panel,
                       PropertyGroup
                       )


# ------------------------------------------------------------------------
#    Scene Properties
# ------------------------------------------------------------------------

class MyProperties(PropertyGroup):

    my_float_vector: FloatVectorProperty(
        name = "Float Vector Value",
        description="Something",
        default=(0.0, 0.0, 0.0), 
        min= 0.0,
        max = 0.1,
        subtype = 'XYZ'
        # 'COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 
        # 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 
        # 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER'
        )

# ------------------------------------------------------------------------
#    Panel in Object Mode
# ------------------------------------------------------------------------

class OBJECT_PT_CustomPanel(Panel):
    bl_idname = "object.custom_panel"
    bl_label = "My Panel"
    bl_space_type = "VIEW_3D"   
    bl_region_type = "UI"
    bl_category = "Tools"
    bl_context = "objectmode"   


    @classmethod
    def poll(self,context):
        return context.object is not None

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        mytool = scene.my_tool

        layout.prop(mytool, "my_float_vector", text="")

# ------------------------------------------------------------------------
#    Registration
# ------------------------------------------------------------------------

classes = (
    MyProperties,
    OBJECT_PT_CustomPanel
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

    bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
    del bpy.types.Scene.my_tool


if __name__ == "__main__":
    register()
$\endgroup$
  • 1
    $\begingroup$ Could argue the node prop highlighted in question is subtype 'TRANSLATION' given the length unit displayed. $\endgroup$ – batFINGER Jun 17 at 9:33
  • $\begingroup$ True, Added. Thanks @batFINGER $\endgroup$ – brockmann Jun 17 at 9:49
0
$\begingroup$

Blender built-in mathutils-Vector

class mathutils.Vector(seq)

This object gives access to Vectors in Blender.

Parameters: seq (sequence of numbers) – Components of the vector, must be a sequence of at least two

mathutils.Vector

Most of the Blender code contain this Vector component for value modification.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.