Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- from math import pi
- class MESH_OT_sedia(bpy.types.Operator):
- """Aggiunge una sedia alla scena"""
- bl_idname = "mesh.primitive_sedia_add"
- bl_label ="Sedia"
- bl_options = {'REGISTER', 'UNDO'}
- lun: bpy.props.FloatProperty(
- name="Lato seduta",
- default=.5,
- unit='LENGTH',
- min=.3,
- soft_max=.6,
- )
- spe: bpy.props.FloatProperty(
- name="Spessore",
- default=.05,
- unit='LENGTH',
- min=.01,
- max=.1,
- )
- alt: bpy.props.FloatProperty(
- name="Altezza",
- default=.5,
- unit='LENGTH',
- min=.4,
- max=.6,
- )
- dia: bpy.props.FloatProperty(
- name="Diametro",
- default=.05,
- unit='LENGTH',
- min=.04,
- max=.1,
- )
- gap: bpy.props.FloatProperty(
- name="Gap Gamba-seduta",
- default=.02,
- unit='LENGTH',
- min=0,
- max=.1,
- )
- loc: bpy.props.FloatVectorProperty(
- name="Posizione",
- default=(0,0),
- size=2,
- unit='LENGTH',
- )
- rot: bpy.props.FloatProperty(
- name="Rotazione",
- default=0,
- unit='ROTATION',
- )
- def execute(self,context):
- lun=self.lun
- spe=self.spe
- alt=self.alt
- dia=self.dia
- gap=self.gap
- loc=self.loc
- rot=self.rot
- bpy.ops.mesh.primitive_cube_add(size=2,location=(loc[0],loc[1],alt+spe/2),scale=(lun,lun,spe),rotation=(0,0,rot))
- seduta=bpy.context.object
- bpy.ops.mesh.primitive_cube_add(size=2,location=(0+lun/2-spe/2,0,lun/2+spe/2),scale=(spe,lun,lun))
- spalliera=bpy.context.object
- spalliera.parent=seduta
- loc_x=lun/2-dia/2-gap
- loc_y=lun/2-dia/2-gap
- bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(loc_x,loc_y,-alt/2-spe/2))
- gambo1=bpy.context.object
- gambo1.parent=seduta
- bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(loc_x,-loc_y,-alt/2-spe/2))
- gambo2=bpy.context.object
- gambo2.parent=seduta
- bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(-loc_x,loc_y,-alt/2-spe/2))
- gambo3=bpy.context.object
- gambo3.parent=seduta
- bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(-loc_x,-loc_y,-alt/2-spe/2))
- gambo4=bpy.context.object
- gambo4.parent=seduta
- return {'FINISHED'}
- def register():
- bpy.utils.register_class(MESH_OT_sedia)
- def unregister():
- bpy.utils.unregister_class(MESH_OT_sedia)
- if __name__ == '__main__':
- register()
Add Comment
Please, Sign In to add comment