我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用bpy.types()。
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()
def unregister(): bpy.utils.unregister_class(CatHideUIList) bpy.utils.unregister_class(CatHidePresetUIList) bpy.utils.unregister_class(CatHidePanel) bpy.utils.unregister_class(CathideRefresh) bpy.utils.unregister_class(CathideApply) bpy.utils.unregister_class(CathidePresetAdd) bpy.utils.unregister_class(CathidePresetDelete) bpy.utils.unregister_class(CathidePresetClear) bpy.utils.unregister_class(CathideApplyPreset) bpy.utils.unregister_class(CatHidePanelList) del bpy.types.Scene.panel_cathide_list bpy.utils.unregister_class(CatHidePresetList) del bpy.types.Scene.preset_cathide_list del bpy.types.Scene.cathide_index del bpy.typse.Scene.cathide_preset_index del bpy.typse.Scene.cathide_show_presetdetails
def get_location(self): op_class = getattr(bpy.types, self.identifier) op_func = getattr(op_class, "execute", None) if op_func is None: op_func = getattr(op_class, "invoke", None) if op_func is None: op_func = getattr(op_class, "poll", None) if op_func: op_code = op_func.__code__ source_path = op_code.co_filename # clear the prefix for p in script_paths: source_path = source_path.split(p)[-1] if source_path[0] in "/\\": source_path = source_path[1:] return source_path, op_code.co_firstlineno else: return None, None
def __repr__(self): # useful display, repr(op) # import bpy idname = self.idname() as_string = op_as_string(idname) # XXX You never quite know what you get from bpy.types, # with operators... Operator and OperatorProperties # are shadowing each other, and not in the same way for # native ops and py ones! See T39158. # op_class = getattr(bpy.types, idname) op_class = op_get_rna(idname) descr = op_class.bl_rna.description # XXX, workaround for not registering # every __doc__ to save time on load. if not descr: descr = op_class.__doc__ if not descr: descr = "" return "# %s\n%s" % (descr, as_string)
def modal(self, context, event): if event.type in {'I', 'A', 'S', 'R', 'F'} and event.value == 'PRESS': self.keyboard(context, event) elif event.type in {'RIGHTMOUSE', 'ESC'}: self.complete(context) bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') return {'FINISHED'} elif event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.drag = True self.cursor_area.enable() self.cursor_fence.disable() self.startPoint = (event.mouse_region_x, event.mouse_region_y) self.endPoint = (event.mouse_region_x, event.mouse_region_y) elif event.type == 'LEFTMOUSE' and event.value == 'RELEASE': self.drag = False self.cursor_area.disable() self.cursor_fence.enable() self.endPoint = (event.mouse_region_x, event.mouse_region_y) self.select(context, self.startPoint, event) elif event.type == 'MOUSEMOVE': self.endPoint = (event.mouse_region_x, event.mouse_region_y) return {'RUNNING_MODAL'}
def init(self, pick_tool, context, action): # Post selection actions self.selectMode = True self.object_location = None self.startPoint = (0, 0) self.endPoint = (0, 0) self.drag = False self.feedback.instructions(context, "Select Lines", "Click & Drag to select lines in area", [ ('SHIFT', 'deselect'), ('CTRL', 'contains'), ('A', 'All'), ('I', 'Inverse'), # ('F', 'Create lines from selection'), ('R', 'Retrieve selection'), ('S', 'Store selection'), ('ESC or RIGHTMOUSE', 'exit when done') ]) self.feedback.enable() args = (self, context) self._handle = bpy.types.SpaceView3D.draw_handler_add( self.draw_callback, args, 'WINDOW', 'POST_PIXEL') self.action = action self._draw(context) print("SelectLines.init()")
def register(): global vars_dict vars_dict = { # spacial tree for segments and points 'seg_tree': None, 'point_tree': None, # keep track of shapely geometry selection sets 'select_polygons': None, 'select_lines': None, 'select_points': None } bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Pick2DPolygons) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Pick2DLines) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Pick2DPoints) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_OutputPolygons) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_OutputLines) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Offset) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Simplify) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Detect) bpy.utils.register_class(ARCHIPACK_OP_PolyLib_Solidify) bpy.utils.register_class(archipack_polylib) bpy.types.WindowManager.archipack_polylib = PointerProperty(type=archipack_polylib) bpy.app.handlers.load_post.append(load_handler)
def init(self, context, event): # Store context data if SnapStore.instances_running < 1: SnapStore.sel = [o for o in context.selected_objects] SnapStore.act = context.active_object bpy.ops.object.select_all(action="DESELECT") SnapStore.use_snap = context.tool_settings.use_snap SnapStore.snap_element = context.tool_settings.snap_element SnapStore.snap_target = context.tool_settings.snap_target SnapStore.pivot_point = context.space_data.pivot_point SnapStore.trans_orientation = context.space_data.transform_orientation self.create_helper(context) SnapStore.instances_running += 1 # print("ArchipackSnapBase init: %s" % (SnapStore.instances_running)) self.set_transform_orientation(context) args = (self, context) self._draw_handler = bpy.types.SpaceView3D.draw_handler_add(SnapStore.draw, args, 'WINDOW', 'POST_PIXEL')
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 unregister(): for cls in reversed(classes): bpy.utils.unregister_class(cls) bpy.app.handlers.frame_change_pre.remove(animate_text) bpy.app.handlers.frame_change_post.remove(textcounter_text_update_frame) bpy.app.handlers.frame_change_pre.remove(textscrambler_update_frame) bpy.app.handlers.frame_change_post.remove(typewriter_text_update_frame) del bpy.types.TextCurve.text_counter_props del bpy.types.TextCurve.scrambler_progress del bpy.types.TextCurve.use_text_scrambler del bpy.types.TextCurve.source_text del bpy.types.TextCurve.characters del bpy.types.TextCurve.character_count del bpy.types.TextCurve.backup_text del bpy.types.TextCurve.use_animated_text del bpy.types.Object.defaultTextBody del bpy.types.Object.startFrame del bpy.types.Object.endFrame del bpy.types.Object.typeSpeed del bpy.types.Object.runAnimation del bpy.types.Object.manualEndFrame
def sculpt(self, menu, context): has_brush = utils_core.get_brush_link(context, types="brush") icons = get_current_brush_icon(has_brush.sculpt_tool) if \ has_brush else "BRUSH_DATA" self.draw_brushes(menu, has_brush, icons, context) menu.add_item().menu(BrushRadiusMenu.bl_idname) if has_brush: # if the active brush is unlinked these menus don't do anything menu.add_item().menu(BrushStrengthMenu.bl_idname) menu.add_item().menu(BrushAutosmoothMenu.bl_idname) menu.add_item().menu(BrushModeMenu.bl_idname) menu.add_item().menu("VIEW3D_MT_sv3_texture_menu") menu.add_item().menu("VIEW3D_MT_sv3_stroke_options") menu.add_item().menu("VIEW3D_MT_sv3_brush_curve_menu") menu.add_item().menu("VIEW3D_MT_sv3_dyntopo") menu.add_item().menu("VIEW3D_MT_sv3_master_symmetry_menu")
def init(self): has_brush = utils_core.get_brush_link(bpy.context, types="brush") if utils_core.get_mode() == utils_core.sculpt: enum = has_brush.bl_rna.properties['sculpt_plane'].enum_items if \ has_brush else None path = "tool_settings.sculpt.brush.sculpt_plane" elif utils_core.get_mode() == utils_core.texture_paint: enum = has_brush.bl_rna.properties['blend'].enum_items if \ has_brush else None path = "tool_settings.image_paint.brush.blend" else: enum = has_brush.bl_rna.properties['vertex_tool'].enum_items if \ has_brush else None path = "tool_settings.vertex_paint.brush.vertex_tool" return enum, path
def draw(self, context): settings = self.init() menu = utils_core.Menu(self) has_brush = utils_core.get_brush_link(context, types="brush") if has_brush: # add the top slider menu.add_item().prop(has_brush, "auto_smooth_factor", slider=True) menu.add_item().separator() # add the rest of the menu items for i in range(len(settings)): utils_core.menuprop( menu.add_item(), settings[i][0], settings[i][1], "tool_settings.sculpt.brush.auto_smooth_factor", icon='RADIOBUT_OFF', disable=True, disable_icon='RADIOBUT_ON' ) else: menu.add_item().label("No Smooth options available", icon="INFO")
def register(): bpy.utils.register_module(__name__) bpy.types.Scene.cloudparticles = BoolProperty( name="Particles", description="Generate Cloud as Particle System", default=False) bpy.types.Scene.cloudsmoothing = BoolProperty( name="Smoothing", description="Smooth Resultant Geometry From Gen Cloud Operation", default=True) bpy.types.Scene.cloud_type = EnumProperty( name="Type", description="Select the type of cloud to create with material settings", items=[("0", "Stratus", "Generate Stratus_foggy Cloud"), ("1", "Cumulous", "Generate Cumulous_puffy Cloud"), ("2", "Cirrus", "Generate Cirrus_wispy Cloud"), ("3", "Explosion", "Generate Explosion"), ], default='0')
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 main_check(obj, info): import array bm = mesh_helpers.bmesh_copy_from_object(obj, transform=False, triangulate=False) edges_non_manifold = array.array('i', (i for i, ele in enumerate(bm.edges) if not ele.is_manifold)) edges_non_contig = array.array('i', (i for i, ele in enumerate(bm.edges) if ele.is_manifold and (not ele.is_contiguous))) info.append(("Non Manifold Edge: %d" % len(edges_non_manifold), (bmesh.types.BMEdge, edges_non_manifold))) info.append(("Bad Contig. Edges: %d" % len(edges_non_contig), (bmesh.types.BMEdge, edges_non_contig))) bm.free()
def main_check(obj, info): import math from mathutils import Vector scene = bpy.context.scene print_3d = scene.print_3d angle_overhang = (math.pi / 2.0) - print_3d.angle_overhang if angle_overhang == math.pi: info.append(("Skipping Overhang", ())) return bm = mesh_helpers.bmesh_copy_from_object(obj, transform=True, triangulate=False) bm.normal_update() z_down = Vector((0, 0, -1.0)) z_down_angle = z_down.angle # 4.0 ignores zero area faces faces_overhang = [ele.index for ele in bm.faces if z_down_angle(ele.normal, 4.0) < angle_overhang] info.append(("Overhang Face: %d" % len(faces_overhang), (bmesh.types.BMFace, faces_overhang))) bm.free()
def register(): bpy.utils.register_module(__name__) bpy.types.Scene.animrenderbake_start = IntProperty( name="Start", description="Start frame of the animated bake", default=1) bpy.types.Scene.animrenderbake_end = IntProperty( name="End", description="End frame of the animated bake", default=250) bpy.types.RENDER_PT_bake.prepend(draw) cycles_panel = getattr(bpy.types, "CyclesRender_PT_bake", None) if cycles_panel: cycles_panel.prepend(draw)
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(align=True) col.label("Settings:") col.prop(self, "types") split = layout.split(percentage=0.95, align=True) col = split.column(align=True) col.prop(self, "scale_x") row = split.row(align=True) row.scale_y = 2.0 col.prop(self, "scale_y") row.prop(self, "link", toggle=True, text="", icon="LINKED")
def make_curve(self, context, verts, lh, rh): types = self.types curve_data = bpy.data.curves.new(name='CurlyCurve', type='CURVE') curve_data.dimensions = '3D' for p in range(len(verts)): c = 0 spline = curve_data.splines.new(type='BEZIER') spline.bezier_points.add(len(verts[p]) / 3 - 1) spline.bezier_points.foreach_set('co', verts[p]) for bp in spline.bezier_points: bp.handle_left_type = 'ALIGNED' bp.handle_right_type = 'ALIGNED' bp.handle_left.xyz = lh[p][c] bp.handle_right.xyz = rh[p][c] c += 1 # something weird with this one if types == 1 or types == 2 or types == 3: spline.bezier_points[3].handle_left.xyz = lh[p][3] object_data_add(context, curve_data, operator=self)
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 elem_props_template_finalize(template, elem): """ Finalize one element's template/props. Issue is, some templates might be "needed" by different types (e.g. NodeAttribute is for lights, cameras, etc.), but values for only *one* subtype can be written as template. So we have to be sure we write those for the other subtypes in each and every elements, if they are not overriden by that element. Yes, hairy, FBX that is to say. When they could easily support several subtypes per template... :( """ for name, (value, ptype_name, animatable, written) in template.items(): if written: continue ptype = FBX_PROPERTIES_DEFINITIONS[ptype_name] _elem_props_set(elem, ptype, name, value, _elem_props_flags(animatable, False, False)) # ##### Templates ##### # TODO: check all those "default" values, they should match Blender's default as much as possible, I guess?
def elem_props_get_number(elem, elem_prop_id, default=None): elem_prop = elem_props_find_first(elem, elem_prop_id) if elem_prop is not None: assert(elem_prop.props[0] == elem_prop_id) if elem_prop.props[1] == b'double': assert(elem_prop.props[1] == b'double') assert(elem_prop.props[2] == b'Number') else: assert(elem_prop.props[1] == b'Number') assert(elem_prop.props[2] == b'') # we could allow other number types assert(elem_prop.props_type[4] == data_types.FLOAT64) return elem_prop.props[4] return default
def elem_props_get_visibility(elem, elem_prop_id, default=None): elem_prop = elem_props_find_first(elem, elem_prop_id) if elem_prop is not None: assert(elem_prop.props[0] == elem_prop_id) assert(elem_prop.props[1] == b'Visibility') assert(elem_prop.props[2] == b'') # we could allow other number types assert(elem_prop.props_type[4] == data_types.FLOAT64) return elem_prop.props[4] return default # ---------------------------------------------------------------------------- # Blender # ------ # Object
def remove_properties(cls): """This is a function that should be called on sub-classes of declarative_property_group in order to ensure that they are un-initialised when the addon is unloaded. """ if cls.ef_initialised: prototype = getattr(bpy.types, cls.__name__) for prop in cls.properties: if hasattr(prototype, prop['attr']): delattr(prototype, prop['attr']) for property_group_parent in cls.ef_attach_to: if property_group_parent is not None: prototype = getattr(bpy.types, property_group_parent) if hasattr(prototype, cls.__name__): delattr(prototype, cls.__name__) cls.ef_initialised = False return cls
def execute(self, context): if bpy.types.Scene.Clay: # Clay activated ac = Alternative_Clay(self, True) if ac is None: if not Exist_Mat(): Create_Mat() rl = context.scene.render.layers rl.active.material_override = Get_Mat() else: context.scene.render.layers.active.material_override = ac bpy.types.Scene.Clay = False else: context.scene.render.layers.active.material_override = None if bpy.types.Scene.Clay_Pinned: if bpy.data.materials[0].users == 0: bpy.data.materials.remove(Get_Mat()) bpy.types.Scene.Clay = True return {'FINISHED'}
def getmodule(opname): addon = True clazz = getclazz(opname) modn = clazz.__module__ try: line = inspect.getsourcelines(clazz)[1] except IOError: line = -1 except TypeError: line = -1 if modn == 'bpy.types': mod = 'C operator' addon = False elif modn != '__main__': mod = sys.modules[modn].__file__ else: addon = False mod = modn return mod, line, addon
def operator_exists(idname): op_name = idname.split(".") name = op_name[0].upper()+"_OT_"+op_name[1] return hasattr(bpy.types,name)
def register(): bpy.utils.register_module(__name__) bpy.types.Scene.ImageResizer = PointerProperty(type=ImageResizerPanelSettings) # ---------------------------------------------------------------------
def unregister(): del bpy.types.Scene.ImageResizer bpy.utils.unregister_module(__name__) # ---------------------------------------------------------------------
def register(): bpy.utils.register_module(__name__) bpy.types.INFO_MT_mesh_add.prepend(menu_draw)
def unregister(): bpy.utils.unregister_module(__name__) bpy.types.INFO_MT_mesh_custom_add.remove(menu_draw)
def register(): for col_name, type_name in SUPPORTED_COLLECTIONS: type = getattr(bpy.types, type_name) type.id = p.IntProperty(name="unique id", get=_create_id_getter(col_name)) counter_name = col_name + "_id_counter" setattr(bpy.types.Scene, counter_name, p.IntProperty(name="unique id counter", default=1)) handlers.load_post.append(load_file) handlers.scene_update_pre.append(load_file_shim)
def unregister(): for col_name, type_name in SUPPORTED_COLLECTIONS: type = getattr(bpy.types, type_name) del type.id counter_name = col_name + "_id_counter" delattr(bpy.types.Scene, counter_name) handlers.load_post.remove(load_file)
def register(): print(__name__) bpy.utils.register_module(__name__) #bpy.utils.register_class(ImportSomeData) bpy.types.INFO_MT_file_import.append(menu_func)
def unregister(): bpy.utils.unregister_module(__name__) #bpy.utils.unregister_class(ImportBmd) bpy.types.INFO_MT_file_import.remove(menu_func)
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 unregister(): bpy.utils.unregister_class(CatHideUIList) bpy.utils.unregister_class(CatHidePanel) bpy.utils.unregister_class(CathideRefresh) bpy.utils.unregister_class(CathideApply) bpy.utils.unregister_class(CatHidePanelList) del bpy.types.Scene.panel_cathide_list del bpy.types.Scene.cathide_index
def unregister(): bpy.utils.unregister_class(CatHideUIList) bpy.utils.unregister_class(CatHideSpecificUIList) bpy.utils.unregister_class(CatHidePresetUIList) bpy.utils.unregister_class(CatHideListActions) bpy.utils.unregister_class(CatHidePanel) bpy.utils.unregister_class(CathideRefresh) bpy.utils.unregister_class(CathideApply) bpy.utils.unregister_class(CathideApplySpecific) bpy.utils.unregister_class(CathidePresetAdd) bpy.utils.unregister_class(CathidePresetUpdate) bpy.utils.unregister_class(CathidePresetDelete) bpy.utils.unregister_class(CathidePresetClear) bpy.utils.unregister_class(CathideApplyPreset) bpy.utils.unregister_class(CathideLoadPreset) bpy.utils.unregister_class(CathideUpdateTemporary) bpy.utils.unregister_class(CathideReset) bpy.utils.unregister_class(CathideCopyPreset) bpy.utils.unregister_class(CatHideDeleteAllPresetsMenu) bpy.utils.unregister_class(CatHideCallClearPresetsMenu) bpy.utils.unregister_class(CatHideUpdatePresetsMenu) bpy.utils.unregister_class(CatHideCallUpdatePresetsMenu) bpy.utils.unregister_class(CatHideCopyPresetsMenu) bpy.utils.unregister_class(CatHidePanelList) del bpy.types.Scene.cathide_panel_list bpy.utils.unregister_class(CatHideSpecificPanelList) del bpy.types.Scene.cathide_specific_panel_list bpy.utils.unregister_class(CatHidePresetList) del bpy.types.Scene.cathide_preset_list del bpy.types.Scene.cathide_index del bpy.types.Scene.cathide_specific_index del bpy.types.Scene.cathide_preset_index del bpy.types.Scene.cathide_show_specific del bpy.types.Scene.cathide_show_specific_details del bpy.types.Scene.cathide_show_preset del bpy.types.Scene.cathide_show_presetcatdetails del bpy.types.Scene.cathide_show_presetspaneldetails del bpy.types.Scene.cathide_show_presetsutility del bpy.types.Scene.cathide_copyallpresets del bpy.types.Scene.cathide_show_onlycontext_specific
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 unregister(): bpy.utils.unregister_class(CatHideUIList) bpy.utils.unregister_class(CatHideSpecificUIList) bpy.utils.unregister_class(CatHidePresetUIList) bpy.utils.unregister_class(CatHidePanel) bpy.utils.unregister_class(CathideRefresh) bpy.utils.unregister_class(CathideApply) bpy.utils.unregister_class(CathideApplySpecific) bpy.utils.unregister_class(CathidePresetAdd) bpy.utils.unregister_class(CathidePresetDelete) bpy.utils.unregister_class(CathidePresetClear) bpy.utils.unregister_class(CathideApplyPreset) bpy.utils.unregister_class(CathideResetCatOnly) bpy.utils.unregister_class(CathideResetPanelOnly) bpy.utils.unregister_class(CatHidePanelList) del bpy.types.Scene.cathide_panel_list bpy.utils.unregister_class(CatHideSpecificPanelList) del bpy.types.Scene.cathide_specific_panel_list bpy.utils.unregister_class(CatHidePresetList) del bpy.types.Scene.cathide_preset_list del bpy.types.Scene.cathide_index del bpy.types.Scene.cathide_specific_index del bpy.types.Scene.cathide_preset_index del bpy.types.Scene.cathide_show_specific del bpy.types.Scene.cathide_show_specific_details del bpy.types.Scene.cathide_show_preset del bpy.types.Scene.cathide_show_presetcatdetails del bpy.types.Scene.cathide_show_presetspaneldetails
def register(): bpy.utils.register_class(VCICenterImage) bpy.types.SEQUENCER_PT_input.append(VCI_panel)
def unregister(): bpy.utils.unregister_class(VCICenterImage) bpy.types.SEQUENCER_PT_input.remove(VCI_panel)
def register(): bpy.utils.register_module(__name__) bpy.types.INFO_MT_mesh_add.append(menu_func)
def unregister(): bpy.utils.unregister_module(__name__) bpy.types.INFO_MT_mesh_add.remove(menu_func)
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)
def _get_py_visible_attrs(self): attrs = [] py_class = getattr(bpy.types, self.identifier) for attr_str in dir(py_class): if attr_str.startswith("_"): continue attrs.append((attr_str, getattr(py_class, attr_str))) return attrs
def get_py_functions(self): import types functions = [] for identifier, attr in self._get_py_visible_attrs(): # methods may be python wrappers to C functions attr_func = getattr(attr, "__func__", attr) if type(attr_func) in {types.FunctionType, types.MethodType}: functions.append((identifier, attr)) return functions
def get_py_c_functions(self): import types functions = [] for identifier, attr in self._get_py_visible_attrs(): # methods may be python wrappers to C functions attr_func = getattr(attr, "__func__", attr) if type(attr_func) in {types.BuiltinMethodType, types.BuiltinFunctionType}: functions.append((identifier, attr)) return functions
def build_property_typemap(skip_classes, skip_typemap): property_typemap = {} for attr in dir(bpy.types): cls = getattr(bpy.types, attr) if issubclass(cls, skip_classes): continue # # to support skip-save we cant get all props # properties = cls.bl_rna.properties.keys() properties = [] for prop_id, prop in cls.bl_rna.properties.items(): if not prop.is_skip_save: properties.append(prop_id) properties.remove("rna_type") property_typemap[attr] = properties if skip_typemap: for cls_name, properties_blacklist in skip_typemap.items(): properties = property_typemap.get(cls_name) if properties is not None: for prop_id in properties_blacklist: try: properties.remove(prop_id) except: print("skip_typemap unknown prop_id '%s.%s'" % (cls_name, prop_id)) else: print("skip_typemap unknown class '%s'" % cls_name) return property_typemap