mkbreuer
(mkbreuer)
1
How can i create an Float Property instead of IntProperty as Value Slider?
http://www.blender.org/api/blender_python_api_2_66_release/bpy.props.html
I have tried some expierence but i fail with this slider.
here is a function example where i want to use it:
class BBox_MirrorExtrudeZ(bpy.types.Operator):
"""mirror extrude in z direction"""
bl_idname = "bbox.mirror_extrude_z"
bl_label = "Mirror Extrude Z"
bl_options = {'REGISTER', 'UNDO'}
extrude_z = bpy.props.IntProperty(name="Extrude Z", description="How long?", default=0, min=0, soft_max=1000, step=1)
origin = bpy.props.BoolProperty(name="Set Back", description="set back", default=True)
def execute(self, context):
print(self)
self.report({'INFO'}, "Extrude Cylinder")
bpy.ops.view3d.snap_cursor_to_selected()
bpy.ops.mesh.select_mode(type='VERT')
bpy.ops.mesh.edge_face_add()
bpy.ops.mesh.normals_make_consistent()
bpy.ops.mesh.extrude_region()
for i in range(self.extrude_z):
bpy.ops.transform.translate(value=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
for i in range(self.origin):
bpy.ops.object.editmode_toggle()
bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
bpy.ops.view3d.snap_selected_to_cursor()
bpy.ops.object.editmode_toggle()
return {'FINISHED'}
veolata
(veolata)
2
bpy.types.Scene.StepMove = FloatProperty(
name = “MvDis”,
description = “MvDis”, default = 0.25,
min = -0.25,
max = 0.5
)
CoDEmanX
(CoDEmanX)
3
subtype=“FACTOR” should do the trick.
mkbreuer
(mkbreuer)
4
veolata: sorry, i don´t know how to use it > it be always error in integer…
CoDEmanX: thanks, it works
mkbreuer
(mkbreuer)
5
Hy CoDEmanX and Veolata,
The IntPropety with subtype=“FACTOR” should work only with plus values.
I want to move my object in minus and plus.
I have tried to set the FloatProp in a easiest way, but it will not work…
import bpy
from bpy import*
from bpy.props import *
from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty
class TestOperator(bpy.types.Operator):
"""Test Operator"""
bl_idname = "object.test_changer"
bl_label = "Test Changer"
bl_options = {'REGISTER', 'UNDO'}
bpy.types.Scene.StepMove = FloatProperty(name = "MvDis", description = "MvDis", default = 1, min = -1, max = 5)
bpy.context.scene.StepMove = 11.0
StepMove = FloatProperty(name = "MvDis", description = "MvDis", default = 0.0, min = -50, max = 50)
def execute(self, context, StepMove):
#for i in range(self.StepMove):
bpy.ops.transform.translate(value=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_popup(self, event)
class Test_Panel(bpy.types.Panel):
bl_label = "Test Panel"
bl_idname = "OBJECT_PT_Test"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("object.test_changer")
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
Thanks for any help!!!
mkbreuer
(mkbreuer)
6
Ok! The subtype=“FACTOR” trick works perfect, but how can i use it for plus and minus value in the easiest way?
example: transform will use ever only the positiv value
class TestOperator(bpy.types.Operator):
“”“Test Operator”“”
bl_idname = “edit.test_operator”
bl_label = “Test Operator”
bl_options = {‘REGISTER’, ‘UNDO’}
move = bpy.props.IntProperty(name = "MvDis", description = "MvDis", default=0, min=-50, max=50, step=1, subtype="FACTOR")
def execute(self, context):
for i in range(self.move):
bpy.ops.transform.translate(value=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
return {'FINISHED'}
Maybe and if/else will do that?..
Defining the value outside the execution?..
Thanks for any help!
mkbreuer
(mkbreuer)
7
my Solution for now:
class TestOperator(bpy.types.Operator):
"""Test Operator"""
bl_idname = "edit.test_operator"
bl_label = "Test Operator"
bl_options = {'REGISTER', 'UNDO'}
move_p = bpy.props.IntProperty(name = "MvDis", description = "MvDis", default=0, min=0, max=500, step=1, subtype="FACTOR")
move_n = bpy.props.IntProperty(name = "MvDis", description = "MvDis", default=0, min=0, max=500, step=1, subtype="FACTOR")
def draw(self, context):
layout = self.layout
row = layout.row(1)
row.prop(self, 'move_p', text="+", icon ="ORTHO")
row.prop(self, 'move_n', text="-", icon ="ORTHO")
def execute(self, context):
for i in range(self.move_p):
bpy.ops.transform.translate(value=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
for i in range(self.move_n):
bpy.ops.transform.translate(value=(0, 0, -1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
return {'FINISHED'}
mkbreuer
(mkbreuer)
8
my Solution for now / works additiv:
class TestOperator(bpy.types.Operator):
"""Test Operator"""
bl_idname = "edit.test_operator"
bl_label = "Test Operator"
bl_options = {'REGISTER', 'UNDO'}
move_p = bpy.props.IntProperty(name = "MvDis", description = "MvDis", default=0, min=0, max=500, step=1, subtype="FACTOR")
move_n = bpy.props.IntProperty(name = "MvDis", description = "MvDis", default=0, min=0, max=500, step=1, subtype="FACTOR")
def draw(self, context):
layout = self.layout
row = layout.row(1)
row.prop(self, 'move_p', text="+", icon ="DISCLOSURE_TRI_RIGHT")
row.prop(self, 'move_n', text="-", icon ="DISCLOSURE_TRI_DOWN")
def execute(self, context):
for i in range(self.move_p):
bpy.ops.transform.translate(value=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
for i in range(self.move_n):
bpy.ops.transform.translate(value=(0, 0, -1), constraint_axis=(False, False, True), constraint_orientation='NORMAL')
return {'FINISHED'}
mkbreuer
(mkbreuer)
9
Anywhere a good Course to find about this stuff outhere?
Please let me know!
I want to get deeper with it…