def register():
bpy.utils.register_class(CatHideUIList)
bpy.utils.register_class(CatHidePresetUIList)
bpy.utils.register_class(CatHidePanel)
bpy.utils.register_class(CathideRefresh)
bpy.utils.register_class(CathideApply)
bpy.utils.register_class(CathidePresetAdd)
bpy.utils.register_class(CathidePresetDelete)
bpy.utils.register_class(CathidePresetClear)
bpy.utils.register_class(CathideApplyPreset)
bpy.utils.register_class(CatHidePanelList)
bpy.types.Scene.panel_cathide_list = \
bpy.props.CollectionProperty(type=CatHidePanelList)
bpy.types.Scene.cathide_index = IntProperty()
bpy.utils.register_class(CatHidePresetList)
bpy.types.Scene.preset_cathide_list = \
bpy.props.CollectionProperty(type=CatHidePresetList)
bpy.types.Scene.cathide_preset_index = IntProperty()
bpy.types.Scene.cathide_show_presetdetails = BoolProperty()
python类props()的实例源码
io_export_md5_codemanx_09122013j_release.py 文件源码
项目:blender-idtech4-md5
作者: motorsep
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def register():
global oldname, oldnamehelper
oldname = {}
oldnamehelper = {}
bpy.types.Bone.Export = bpy.props.BoolProperty(
name = "export",
description = "Will this bone be exported?",
default = False)
bpy.types.Bone.ReparentBool = bpy.props.BoolProperty(
name = "reparent",
description = "Will this bone be reparented?",
default = False)
bpy.types.Bone.ReparentName = bpy.props.StringProperty(
name = "to",
description = "Reparenting to this bone for export",
default = "")
bpy.utils.register_module(__name__) #mikshaw
bpy.types.INFO_MT_file_export.append(menu_func)
bpy.app.handlers.save_pre.append(fakeuser_for_actions)
bpy.app.handlers.scene_update_post.append(sceneupdate_handler)
def event_dispatcher(self, context, type_op):
if type_op == 'start':
wm = context.window_manager
self._timer = wm.event_timer_add(self.speed, context.window)
wm.modal_handler_add(self)
osc_statemachine['status'] = RUNNING
props = context.scene.generic_osc
paths = context.scene.generic_osc_list
start_server_comms(props.ip, props.port, [i.path for i in paths])
if type_op == 'end':
# osc_statemachine['server'].shutdown()
osc_statemachine['server'].shutdown()
osc_statemachine['server'].server_close()
osc_statemachine['status'] = STOPPED
def register():
from bpy.types import Scene
from bpy.props import (BoolProperty,
IntProperty,
StringProperty,
)
Scene.pc_pc2_rotx = BoolProperty(default=True, name="Rotx = 90")
Scene.pc_pc2_world_space = BoolProperty(default=True, name="World Space")
Scene.pc_pc2_modifiers = BoolProperty(default=True, name="Apply Modifiers")
Scene.pc_pc2_subsurf = BoolProperty(default=True, name="Turn Off SubSurf")
Scene.pc_pc2_start = IntProperty(default=0, name="Frame Start")
Scene.pc_pc2_end = IntProperty(default=100, name="Frame End")
Scene.pc_pc2_group = StringProperty()
Scene.pc_pc2_folder = StringProperty(default="Set me Please!")
Scene.pc_pc2_exclude = StringProperty(default="*")
bpy.utils.register_module(__name__)
update_panel(None, bpy.context)
def execute(self, context):
if context.mode == "OBJECT":
o = context.active_object
props = archipack_reference_point.datablock(o)
if props is None:
return {'CANCELLED'}
bpy.ops.object.select_all(action="DESELECT")
bpy.ops.archipack.reference_point(location_3d=props.location_3d)
for child in o.children:
child.select = True
bpy.ops.archipack.parent_to_reference()
context.scene.objects.unlink(o)
return {'FINISHED'}
else:
self.report({'WARNING'}, "Archipack: Option only valid in Object mode")
return {'CANCELLED'}
def execute(self, context):
if context.mode == "OBJECT":
o = context.active_object
props = archipack_reference_point.datablock(o)
if props is None:
return {'CANCELLED'}
sel = [obj for obj in context.selected_objects if obj != o and obj.parent != o]
itM = o.matrix_world.inverted()
# print("parent_to_reference parenting:%s objects" % (len(sel)))
for child in sel:
rs = child.matrix_world.to_3x3().to_4x4()
loc = itM * child.matrix_world.translation
child.parent = None
child.matrix_parent_inverse.identity()
child.location = Vector((0, 0, 0))
child.parent = o
child.matrix_world = rs
child.location = loc
return {'FINISHED'}
else:
self.report({'WARNING'}, "Archipack: Option only valid in Object mode")
return {'CANCELLED'}
def update_fpath(self, context):
global start_up
start_up=False
ReadLabel(bpy.context.scene.fpath)
if Message != "":
start_up=True
else:
typ = bpy.types.Scene
var = bpy.props
typ.FromLat = var.FloatProperty(description="From Latitude", min=float(MINIMUM_LATITUDE), max=float(MAXIMUM_LATITUDE), precision=3, default=0.0)
typ.ToLat = var.FloatProperty(description="To Latitude", min=float(MINIMUM_LATITUDE), max=float(MAXIMUM_LATITUDE), precision=3)
typ.FromLong = var.FloatProperty(description="From Longitude", min=float(WESTERNMOST_LONGITUDE), max=float(EASTERNMOST_LONGITUDE), precision=3)
typ.ToLong = var.FloatProperty(description="To Longitude", min=float(WESTERNMOST_LONGITUDE), max=float(EASTERNMOST_LONGITUDE), precision=3)
typ.Scale = var.IntProperty(description="Scale", min=1, max=100, default=1)
typ.Magnify = var.BoolProperty(description="Magnify", default=False)
#Import the data and draw the planet
def initialize():
global MAXIMUM_LATITUDE, MINIMUM_LATITUDE
global WESTERNMOST_LONGITUDE, EASTERNMOST_LONGITUDE
global LINES, LINE_SAMPLES, SAMPLE_BITS, MAP_RESOLUTION
global OFFSET, SCALING_FACTOR
global SAMPLE_TYPE, UNIT, TARGET_NAME, RadiusUM, Message
global start_up
LINES = LINE_SAMPLES = SAMPLE_BITS = MAP_RESOLUTION = 0
MAXIMUM_LATITUDE = MINIMUM_LATITUDE = 0.0
WESTERNMOST_LONGITUDE = EASTERNMOST_LONGITUDE = 0.0
OFFSET = SCALING_FACTOR = 0.0
SAMPLE_TYPE = UNIT = TARGET_NAME = RadiusUM = Message = ""
start_up=True
bpy.types.Scene.fpath = bpy.props.StringProperty(
name="Import File ",
description="Select your img file",
subtype="FILE_PATH",
default="",
update=update_fpath)
def register():
bpy.utils.register_class(CubeMapInfo)
bpy.utils.register_class(CubeMapSetup)
bpy.types.Scene.cube_map = bpy.props.PointerProperty(
name="cube_map",
type=CubeMapInfo,
options={'HIDDEN'},
)
bpy.utils.register_class(RENDER_PT_cube_map)
bpy.app.handlers.render_init.append(cube_map_render_init)
bpy.app.handlers.render_pre.append(cube_map_render_pre)
bpy.app.handlers.render_post.append(cube_map_render_post)
bpy.app.handlers.render_cancel.append(cube_map_render_cancel)
bpy.app.handlers.render_complete.append(cube_map_render_complete)
def save(self):
scn = bpy.context.scene
cats = set([cat.name for cat in self.cats])
libpath = bpy.context.scene.matlib.current_library.path
cmd = """
print(30*"+")
import bpy
if not hasattr(bpy.context.scene, "matlib_categories"):
class EmptyProps(bpy.types.PropertyGroup):
pass
bpy.utils.register_class(EmptyProps)
bpy.types.Scene.matlib_categories = bpy.props.CollectionProperty(type=EmptyProps)
cats = bpy.context.scene.matlib_categories
for cat in cats:
cats.remove(0)
"""
for cat in cats:
cmd += """
cat = cats.add()
cat.name = "%s" """ % cat.capitalize()
cmd +='''
bpy.ops.wm.save_mainfile(filepath="%s", check_existing=False, compress=True)''' % winpath(libpath)
return send_command(cmd, "save_categories.py")
def draw(self, context):
self.layout.operator_context = 'INVOKE_REGION_WIN'
self.layout.operator("mesh.archimesh_room", text="Add Room")
self.layout.operator("mesh.archimesh_door", text="Add Door")
self.layout.operator("mesh.archimesh_window", text="Add Rail Window")
self.layout.operator("mesh.archimesh_winpanel", text="Add Panel Window")
self.layout.operator("mesh.archimesh_kitchen", text="Add Cabinet")
self.layout.operator("mesh.archimesh_shelves", text="Add Shelves")
self.layout.operator("mesh.archimesh_column", text="Add Column")
self.layout.operator("mesh.archimesh_stairs", text="Add Stairs")
self.layout.operator("mesh.archimesh_roof", text="Add Roof")
self.layout.menu("INFO_MT_mesh_decoration_add", text="Decoration props", icon="GROUP")
# --------------------------------------------------------------
# Register all operators and panels
# --------------------------------------------------------------
# Add-ons Preferences Update Panel
# Define Panel classes for updating
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
# AddObjectHelper props
col.prop(self, "view_align")
col.prop(self, "location")
col.prop(self, "rotation")
col = layout.column()
col.label("Curve:")
col.prop(self, "types")
col = layout.column(align=True)
col.label("Resize:")
col.prop(self, "scale_x")
col.prop(self, "scale_y")
def draw_curve(props, context):
if props.spiral_type == 'ARCH':
verts = make_spiral(props, context)
if props.spiral_type == 'LOG':
verts = make_spiral(props, context)
if props.spiral_type == 'SPHERE':
verts = make_spiral_spheric(props, context)
if props.spiral_type == 'TORUS':
verts = make_spiral_torus(props, context)
curve_data = bpy.data.curves.new(name='Spiral', type='CURVE')
curve_data.dimensions = '3D'
spline = curve_data.splines.new(type=props.curve_type)
"""
if props.curve_type == 0:
spline = curve_data.splines.new(type='POLY')
elif props.curve_type == 1:
spline = curve_data.splines.new(type='NURBS')
"""
spline.points.add(len(verts) * 0.25 - 1)
# Add only one quarter of points as elements in verts,
# because verts looks like: "x,y,z,?,x,y,z,?,x,..."
spline.points.foreach_set('co', verts)
new_obj = object_data_add(context, curve_data)
def execute(self,context):
props = self.properties
R = props.R
ob = context.object
layers = 20*[False]
layers[0] = True
if ob:
if ob.pov.imported_cyl_loc:
LOC = ob.pov.imported_cyl_loc
if ob.pov.imported_cyl_loc_cap:
LOC_CAP = ob.pov.imported_cyl_loc_cap
else:
if not props.imported_cyl_loc:
LOC_CAP = LOC = bpy.context.scene.cursor_location
LOC_CAP[2] += 2.0
else:
LOC = props.imported_cyl_loc
LOC_CAP = props.imported_cyl_loc_cap
self.report({'INFO'}, "This native POV-Ray primitive "
"won't have any vertex to show in edit mode")
pov_cylinder_define(context, self, None, self.R, LOC, LOC_CAP)
return {'FINISHED'}
def execute(self, context):
props = context.scene.muv_props.texlock
obj = bpy.context.active_object
bm = bmesh.from_edit_mesh(obj.data)
if muv_common.check_version(2, 73, 0) >= 0:
bm.verts.ensure_lookup_table()
bm.edges.ensure_lookup_table()
bm.faces.ensure_lookup_table()
if not bm.loops.layers.uv:
self.report(
{'WARNING'}, "Object must have more than one UV map")
return {'CANCELLED'}
props.verts_orig = [
{"vidx": v.index, "vco": v.co.copy(), "moved": False}
for v in bm.verts if v.select]
return {'FINISHED'}
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
props = layout.operator("view3d.enable_manipulator", text='Translate', icon='MAN_TRANS')
props.translate = True
props = layout.operator("view3d.enable_manipulator", text='Rotate', icon='MAN_ROT')
props.rotate = True
props = layout.operator("view3d.enable_manipulator", text='Scale', icon='MAN_SCALE')
props.scale = True
UseSeparator(self, context)
props = layout.operator("view3d.enable_manipulator", text='Combo', icon='MAN_SCALE')
props.scale = True
props.rotate = True
props.translate = True
props = layout.operator("view3d.enable_manipulator", text='Hide', icon='MAN_SCALE')
props.scale = False
props.rotate = False
props.translate = False
# ********** Object Mirror **********
def draw(self, context):
from math import pi
layout = self.layout
layout.operator_enum("view3d.view_orbit", "type")
props = layout.operator("view3d.view_orbit", "Orbit Opposite")
props.type = 'ORBITRIGHT'
props.angle = pi
UseSeparator(self, context)
layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
UseSeparator(self, context)
layout.operator_enum("view3d.view_pan", "type")
UseSeparator(self, context)
layout.operator("view3d.zoom", text="Zoom In").delta = 1
layout.operator("view3d.zoom", text="Zoom Out").delta = -1
UseSeparator(self, context)
layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
UseSeparator(self, context)
layout.operator("view3d.fly")
layout.operator("view3d.walk")
def draw(self, context):
layout = self.layout
props = layout.operator("view3d.viewnumpad", text="Top")
props.align_active = True
props.type = 'TOP'
props = layout.operator("view3d.viewnumpad", text="Bottom")
props.align_active = True
props.type = 'BOTTOM'
props = layout.operator("view3d.viewnumpad", text="Front")
props.align_active = True
props.type = 'FRONT'
props = layout.operator("view3d.viewnumpad", text="Back")
props.align_active = True
props.type = 'BACK'
props = layout.operator("view3d.viewnumpad", text="Right")
props.align_active = True
props.type = 'RIGHT'
props = layout.operator("view3d.viewnumpad", text="Left")
props.align_active = True
props.type = 'LEFT'
def draw(self, context):
layout = self.layout
layout.operator("view3d.select_border")
layout.operator("armature.select_all")
layout.operator("armature.select_inverse", text="Inverse")
layout.operator("armature.select_hierarchy",
text="Parent").direction = 'PARENT'
layout.operator("armature.select_hierarchy",
text="Child").direction = 'CHILD'
props = layout.operator("armature.select_hierarchy",
text="Extend Parent")
props.extend = True
props.direction = 'PARENT'
props = layout.operator("armature.select_hierarchy",
text="Extend Child")
props.extend = True
props.direction = 'CHILD'
layout.operator("object.select_pattern", text="Select Pattern...")
def draw(self, context):
layout = self.layout
props = layout.operator("pose.select_hierarchy", text="Parent")
props.extend = False
props.direction = 'PARENT'
props = layout.operator("pose.select_hierarchy", text="Child")
props.extend = False
props.direction = 'CHILD'
props = layout.operator("pose.select_hierarchy", text="Extend Parent")
props.extend = True
props.direction = 'PARENT'
props = layout.operator("pose.select_hierarchy", text="Extend Child")
props.extend = True
props.direction = 'CHILD'
def execute(self, context):
if context.mode == "OBJECT":
o = context.active_object
props = archipack_reference_point.datablock(o)
if props is None:
return {'CANCELLED'}
bpy.ops.object.select_all(action="DESELECT")
bpy.ops.archipack.reference_point(location_3d=props.location_3d)
for child in o.children:
child.select = True
bpy.ops.archipack.parent_to_reference()
context.scene.objects.unlink(o)
return {'FINISHED'}
else:
self.report({'WARNING'}, "Archipack: Option only valid in Object mode")
return {'CANCELLED'}
def register():
'''
Register
'''
# register module
registerModule = bpy.utils.register_module
# window manager
windowManager = bpy.types.WindowManager
# pointer property
pointerProperty = bpy.props.PointerProperty
# register
registerModule(__name__)
# armature data ui pointer property
windowManager.armatureDataUI = pointerProperty(type=armatureData)
# button
bpy.types.BONE_PT_display.append(button)
# Unregister
def draw_curve(props, context):
if props.spiral_type == 1:
verts = make_spiral(props, context)
if props.spiral_type == 2:
verts = make_spiral(props, context)
if props.spiral_type == 3:
verts = make_spiral_spheric(props, context)
if props.spiral_type == 4:
verts = make_spiral_torus(props, context)
curve_data = bpy.data.curves.new(name='Spiral', type='CURVE')
curve_data.dimensions = '3D'
if props.curve_type == 0:
spline = curve_data.splines.new(type='POLY')
elif props.curve_type == 1:
spline = curve_data.splines.new(type='NURBS')
spline.points.add( len(verts)*0.25-1 ) #Add only one quarter of points as elements in verts, because verts looks like: "x,y,z,?,x,y,z,?,x,..."
spline.points.foreach_set('co', verts)
new_obj = object_data_add(context, curve_data)
def register():
bpy.utils.register_class(ListItem)
bpy.utils.register_class(MY_UL_List)
bpy.utils.register_class(LIST_OT_NewItem)
bpy.utils.register_class(LIST_OT_DeleteItem)
bpy.utils.register_class(PT_FiltersList)
bpy.types.Scene.my_list = prop.CollectionProperty(type = ListItem)
bpy.types.Scene.list_index = prop.IntProperty(name = "Index for my_list", default = 0)
bpy.types.Scene.aas=bpy.props.EnumProperty(items=populateFilterSelector, name="2DFilter")
def register():
bpy.utils.register_class(CatHideUIList)
bpy.utils.register_class(CatHidePanel)
bpy.utils.register_class(CathideRefresh)
bpy.utils.register_class(CathideApply)
bpy.utils.register_class(CatHidePanelList)
bpy.types.Scene.panel_cathide_list = \
bpy.props.CollectionProperty(type=CatHidePanelList)
bpy.types.Scene.cathide_index = IntProperty()
def register():
bpy.utils.register_class(CatHideUIList)
bpy.utils.register_class(CatHideSpecificUIList)
bpy.utils.register_class(CatHidePresetUIList)
bpy.utils.register_class(CatHidePanel)
bpy.utils.register_class(CathideRefresh)
bpy.utils.register_class(CathideApply)
bpy.utils.register_class(CathideApplySpecific)
bpy.utils.register_class(CathidePresetAdd)
bpy.utils.register_class(CathidePresetDelete)
bpy.utils.register_class(CathidePresetClear)
bpy.utils.register_class(CathideApplyPreset)
bpy.utils.register_class(CathideResetCatOnly)
bpy.utils.register_class(CathideResetPanelOnly)
bpy.utils.register_class(CatHidePanelList)
bpy.types.Scene.cathide_panel_list = \
bpy.props.CollectionProperty(type=CatHidePanelList)
bpy.types.Scene.cathide_index = IntProperty()
bpy.utils.register_class(CatHideSpecificPanelList)
bpy.types.Scene.cathide_specific_panel_list = \
bpy.props.CollectionProperty(type=CatHideSpecificPanelList)
bpy.types.Scene.cathide_specific_index = IntProperty()
bpy.utils.register_class(CatHidePresetList)
bpy.types.Scene.cathide_preset_list = \
bpy.props.CollectionProperty(type=CatHidePresetList)
bpy.types.Scene.cathide_preset_index = IntProperty()
bpy.types.Scene.cathide_show_specific = BoolProperty()
bpy.types.Scene.cathide_show_specific_details = BoolProperty()
bpy.types.Scene.cathide_show_preset = BoolProperty()
bpy.types.Scene.cathide_show_presetcatdetails = BoolProperty()
bpy.types.Scene.cathide_show_presetspaneldetails = BoolProperty()
def draw_buttons(self, context, layout):
props = self.compile().properties
for name in props.keys():
layout.prop(self, name)
def draw_buttons(self, context, layout):
props = self.get_cls(self.bl_idname).properties
for name in props.keys():
layout.prop(self, name)
def stateful(cls):
"""
class decorator for creating stateful class
"""
func = cls()
get_signature(func)
module_name = func.__module__.split(".")[-2]
props = {}
for name, prop in getattr(cls, 'properties', {}).items():
if isinstance(prop, SvRxBaseTypeP):
props[name] = prop.get_prop()
else:
props[name] = prop
props.update(func.properties)
class InnerStateful(cls, Stateful):
category = module_name
inputs_template = func.inputs_template.copy()
outputs_template = func.outputs_template.copy()
properties = props.copy()
parameters = func.parameters.copy()
returns = func.returns.copy()
func_new = InnerStateful()
class_factory(func_new)
InnerStateful.node_cls = func_new.cls
NodeStateful.add_cls(cls.bl_idname, InnerStateful)
return InnerStateful
def register():
bpy.utils.register_module(__name__)
# Extend the scene class here to include the addon data
bpy.types.Scene.freesound_data = bpy.props.PointerProperty(type=FreeSoundData)