Python bpy.types 模块,Panel() 实例源码

我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用bpy.types.Panel()

项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.cathide_panel_list

        for p in plist:
            if p.panelstate==False:
                if p.keep_cat_hidden!=True:
                    p.panelstate=True
        bpy.ops.cathide.apply()

        info = 'Tool Shelf Categories Reset'
        self.report({'INFO'}, info)

        return {'FINISHED'}

# Reset Cathide Panel Only
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        element = context.active_object
        # Restore cursor in case of unhandled Exception
        w = context.window_manager.windows[0]
        w.cursor_modal_restore()
        # Panel
        split = layout.split(.6)  # namelist
        split.prop(element, "bf_namelist_cls", text="")
        row = split.row(align=True)  # aspect
        row.prop(element, "show_transparent", icon="GHOST", text="")
        row.prop(element, "draw_type", text="")
        element.bf_namelist.draw(context, layout)
        row = layout.row()
        if element.bf_has_tmp: row.operator("object.bf_hide_fds_geometry")
        else: row.operator("object.bf_show_fds_geometry")
        row.operator("object.bf_show_fds_code", text="Show FDS Code")
        row.operator("object.bf_props_to_sel_obs", text="Copy To")
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        element = context.material
        # Restore cursor in case of unhandled Exception
        w = context.window_manager.windows[0]
        w.cursor_modal_restore()
        # Panel
        split = layout.split(.7) # namelist
        split.prop(element, "bf_namelist_cls", text="")
        row = split.row(align=True) # aspect
        row.prop(element, "diffuse_color", text="")
        row.prop(element, "alpha", text="")
        element.bf_namelist.draw(context, layout)
        # Other operators
        row = layout.row()
        row.operator("material.bf_show_fds_code", text="Show FDS Code")
        row.operator("material.bf_surf_to_sel_obs", text="Assign To")
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, flt_flag):
        scene=bpy.context.scene
        plist=scene.cathide_panel_list
        idx=scene.cathide_index

        if item.name=="Hide Panel":
            layout.label(item.name)
        else:
            layout.label(item.name)
            layout.prop(item, "specific_panel_state", text="", emboss=True)
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):

        if item.name=="Hide Panel":
            layout.label(item.name)
        else:
            layout.label(item.name)
            layout.prop(item, "specific_panel_state", text="", emboss=True)
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def create(self, context):
        """
            expose only basic params in operator
            use object property for other params
        """
        m = bpy.data.meshes.new("Panel")
        o = bpy.data.objects.new("Panel", m)
        d = m.archipack_door_panel.add()
        d.x = self.x
        d.y = self.y
        d.z = self.z
        d.model = self.model
        d.direction = self.direction
        d.chanfer = self.chanfer
        d.panel_border = self.panel_border
        d.panel_bottom = self.panel_bottom
        d.panel_spacing = self.panel_spacing
        d.panels_distrib = self.panels_distrib
        d.panels_x = self.panels_x
        d.panels_y = self.panels_y
        d.handle = self.handle
        context.scene.objects.link(o)
        o.lock_location[0] = True
        o.lock_location[1] = True
        o.lock_location[2] = True
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        o.lock_scale[0] = True
        o.lock_scale[1] = True
        o.lock_scale[2] = True
        o.select = True
        context.scene.objects.active = o
        d.update(context)
        MaterialUtils.add_door_materials(o)
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        return o
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def create(self, context):
        m = bpy.data.meshes.new("Window Panel")
        o = bpy.data.objects.new("Window Panel", m)
        d = m.archipack_window_panel.add()
        d.center = self.center
        d.origin = self.origin
        d.size = self.size
        d.radius = self.radius
        d.frame_y = self.frame_y
        d.frame_x = self.frame_x
        d.curve_steps = self.curve_steps
        d.shape = self.shape
        d.fixed = self.fixed
        d.pivot = self.pivot
        d.angle_y = self.angle_y
        d.side_material = self.side_material
        d.handle = self.handle
        d.handle_model = self.handle_model
        d.handle_altitude = self.handle_altitude
        context.scene.objects.link(o)
        o.select = True
        context.scene.objects.active = o
        o.lock_location[0] = True
        o.lock_location[1] = True
        o.lock_location[2] = True
        o.lock_rotation[1] = True
        o.lock_scale[0] = True
        o.lock_scale[1] = True
        o.lock_scale[2] = True
        d.update(context)
        MaterialUtils.add_window_materials(o)
        return o
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout

        layout.operator("gpencil.interpolate", text="Interpolate")
        layout.operator("gpencil.interpolate_sequence", text="Sequence")


# ********** Panel **********
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def _sp_items_update(self, context):
    # Get the right space on screen (Properties Panel)
    space = context.space_data
    if space and space.type != 'PROPERTIES': # I am not called by the Properties Panel
        space = None
        for window in context.window_manager.windows:
            for area in window.screen.areas:
                if area.type == 'PROPERTIES':
                    space = area.spaces[0]
                    break
    if not space: return
    # Update Properties Panel context
    try: space.context = self.bf_sp_context
    except TypeError: self.bf_sp_context = 'SCENE'
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def _treat_unused_bl_classes():
    """Treat (rewire or unregister) unused Blender bpy.types"""
    for bt_name in dir(bpy.types):
        # Init
        bt_cls = getattr(bpy.types, bt_name, None)
        bt_bl_space_type = getattr(bt_cls, "bl_space_type", None)
        # Surely used bts
        if bt_bl_space_type in _used_bl_space_type: continue
        # Other Headers and Panels
        # Panels
        if issubclass(bt_cls, Panel):
            if bt_name in _used_panels: continue
            if bt_name not in _unused_panels and bt_bl_space_type in _used_panel_by_bl_space_type:
                bt_bl_category = getattr(bt_cls, "bl_category", None)
                if bt_bl_category and bt_bl_category in _used_panel_by_bl_category: continue
                bt_bl_region_type = getattr(bt_cls, "bl_region_type", None)
                if bt_bl_region_type and bt_bl_region_type in _used_panel_by_bl_region_type: continue
            # If nothing else applies, unregister the Panel
            if DEBUG: print("BFDS: Unregister Panel:", bt_name)
            bpy.utils.unregister_class(bt_cls)
            continue
        # Headers
        if issubclass(bt_cls, Header):
            if bt_name in _used_headers: continue
            if DEBUG: print("BFDS: Rewire Header:", bt_name)
            bt_cls.draw = _unused_header_draw # Unused header, rewire its draw function
            continue
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        element = context.scene
        # Panel
        self.bf_namelist(element).draw(context, layout)
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        element = context.scene
        # Restore cursor in case of unhandled Exception
        w = context.window_manager.windows[0]
        w.cursor_modal_restore()
        # Panel
        self.bf_namelist(element).draw(context, layout)
        # Other operators
        row = layout.row()
        row.operator("scene.bf_restore_all_tmp_objects")
        row.operator("scene.bf_show_fds_code", text="Show FDS Code")
        row.operator("scene.bf_props_to_scene", text="Copy To")
项目:blenderfds    作者:firetools    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        element = context.active_object
        # Restore cursor in case of unhandled Exception
        w = context.window_manager.windows[0]
        w.cursor_modal_restore()
        # Panel
        layout.operator("object.bf_hide_fds_geometry_from_tmp")

### Material panel
项目:archipack    作者:s-leger    | 项目源码 | 文件源码
def create(self, context):
        """
            expose only basic params in operator
            use object property for other params
        """
        m = bpy.data.meshes.new("Panel")
        o = bpy.data.objects.new("Panel", m)
        d = m.archipack_door_panel.add()
        d.x = self.x
        d.y = self.y
        d.z = self.z
        d.model = self.model
        d.direction = self.direction
        d.chanfer = self.chanfer
        d.panel_border = self.panel_border
        d.panel_bottom = self.panel_bottom
        d.panel_spacing = self.panel_spacing
        d.panels_distrib = self.panels_distrib
        d.panels_x = self.panels_x
        d.panels_y = self.panels_y
        d.handle = self.handle
        context.scene.objects.link(o)
        o.lock_location[0] = True
        o.lock_location[1] = True
        o.lock_location[2] = True
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        o.lock_scale[0] = True
        o.lock_scale[1] = True
        o.lock_scale[2] = True
        o.select = True
        context.scene.objects.active = o
        m = o.archipack_material.add()
        m.category = "door"
        m.material = self.material
        d.update(context)
        # MaterialUtils.add_door_materials(o)
        o.lock_rotation[0] = True
        o.lock_rotation[1] = True
        return o
项目:archipack    作者:s-leger    | 项目源码 | 文件源码
def create(self, context):
        m = bpy.data.meshes.new("Window Panel")
        o = bpy.data.objects.new("Window Panel", m)
        d = m.archipack_window_panel.add()
        d.center = self.center
        d.origin = self.origin
        d.size = self.size
        d.radius = self.radius
        d.frame_y = self.frame_y
        d.frame_x = self.frame_x
        d.curve_steps = self.curve_steps
        d.shape = self.shape
        d.fixed = self.fixed
        d.pivot = self.pivot
        d.angle_y = self.angle_y
        d.side_material = self.side_material
        d.handle = self.handle
        d.handle_model = self.handle_model
        d.handle_altitude = self.handle_altitude
        d.enable_glass = self.enable_glass
        context.scene.objects.link(o)
        o.select = True
        context.scene.objects.active = o
        m = o.archipack_material.add()
        m.category = "window"
        m.material = self.material
        o.lock_location[1] = True
        o.lock_location[2] = True
        o.lock_rotation[1] = True
        o.lock_scale[0] = True
        o.lock_scale[1] = True
        o.lock_scale[2] = True
        d.update(context)
        return o
项目:BetterBlender    作者:bobtherobot    | 项目源码 | 文件源码
def draw(self, context):
        layout = self.layout
        wm = context.window_manager
        preferences = bpy.context.user_preferences.addons['ui_change_category'].preferences

        col = layout.column(align=False)
        col.label("Panel:")
        col.prop_search(wm, "chosen_panel",  preferences, "tool_panels",  text="", icon="MENU_PANEL")
        if wm.chosen_panel:
            col.prop(wm, "panel_category")
        col.operator("wm.save_userpref")
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.cathide_panel_list
        slist=scene.cathide_specific_panel_list
        slist2=scene.cathide_temporary_panel_list
        toregister=[]
        orderlist=[]

        #save temporary panels details
        for p in slist2:
            for p2 in slist:
                if p.name==p2.name:
                    if p.panel_context==p2.panel_context:
                        if p.panel_module==p2.panel_module:
                            p2.specific_panel_state=p.specific_panel_state

        #get cat order:
        for c in plist:
            orderlist.append(c.name)

        #get cat to register
        for p in plist:
            if p.panelstate==True:
                toregister.append(p.name)

        #unregister all cat       
        for p in plist:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p.name:
                                        if "bl_rna" in panel.__dict__:
                                            bpy.utils.unregister_class(panel)

        #register cats in order        
        for p in orderlist:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        for p2 in toregister:
                                            if p==p2:
                                                if "bl_rna" not in panel.__dict__:
                                                    bpy.utils.register_class(panel)

        bpy.ops.cathide.refresh()

        info = 'Tool Shelf Categories Configuration applied'
        self.report({'INFO'}, info)

        return {'FINISHED'} 

# apply cathide N Panels configuration
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.panel_cathide_list

        #clear panel list
        for i in range(len(plist)-1,-1,-1):
            plist.remove(i)

        #declare category list
        catlistreg1=[]
        catlistreg2=[]
        catlistunreg1=[]
        catlistunreg2=[]
        catlistunreg3=[]
        #find category and append them in the list
        for panel in bpy.types.Panel.__subclasses__():
            if hasattr(panel, 'bl_space_type'):
                if hasattr(panel, 'bl_region_type'):
                    if hasattr(panel, 'bl_category'):
                        if panel.bl_space_type=="VIEW_3D":
                            if panel.bl_region_type=="TOOLS":
                                if "bl_rna" not in panel.__dict__:
                                    catlistunreg1.append(panel.bl_category)
                                elif "bl_rna" in panel.__dict__:
                                    catlistreg1.append(panel.bl_category)

        for c1 in list(set(catlistreg1)):
            catlistreg2.append(c1)

        for c1 in list(set(catlistunreg1)):
            catlistunreg2.append(c1)

        l1=Counter(catlistreg2)
        l2=Counter(catlistunreg2)
        diff=l2-l1

        for c in list(diff.elements()):
            catlistunreg3.append(c)

        for c2 in catlistreg2:
            newcat=plist.add()
            newcat.name=c2

        for c3 in catlistunreg3:
            newcat=plist.add()
            newcat.name=c3
            newcat.panelstate=False

        info = 'Panel List refreshed'
        self.report({'INFO'}, info)

        return {'FINISHED'}

# apply cathide configuration
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.panel_cathide_list
        toregister=[]
        tounregister=[]

        #register
        for p in plist:
            if p.panelstate==True:
                toregister.append(p.name)

        for p in toregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        if "bl_rna" not in panel.__dict__:
                                            bpy.utils.register_class(panel)
        #unregister
        for p in plist:
            if p.panelstate==False:
                tounregister.append(p.name)

        for p in tounregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        if "bl_rna" in panel.__dict__:
                                            bpy.utils.unregister_class(panel)

        bpy.ops.cathide.refresh()

        info = 'Unselected Panels Hidden'
        self.report({'INFO'}, info)

        return {'FINISHED'} 

# Create custom property group
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.cathide_panel_list
        slist=scene.cathide_specific_panel_list
        slist2=scene.cathide_temporary_panel_list
        toregister=[]
        orderlist=[]

        #save temporary panels details
        for p in slist2:
            for p2 in slist:
                if p.name==p2.name:
                    if p.panel_context==p2.panel_context:
                        if p.panel_module==p2.panel_module:
                            p2.specific_panel_state=p.specific_panel_state

        #get cat order:
        for c in plist:
            orderlist.append(c.name)

        #get cat to register
        for p in plist:
            if p.panelstate==True:
                toregister.append(p.name)

        #unregister all cat       
        for p in plist:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p.name:
                                        if "bl_rna" in panel.__dict__:
                                            bpy.utils.unregister_class(panel)

        #register cats in order        
        for p in orderlist:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        for p2 in toregister:
                                            if p==p2:
                                                if "bl_rna" not in panel.__dict__:
                                                    bpy.utils.register_class(panel)

        bpy.ops.cathide.refresh()

        info = 'Tool Shelf Categories Configuration applied'
        self.report({'INFO'}, info)

        return {'FINISHED'} 

# apply specific panel cathide configuration
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.cathide_panel_list
        idx=scene.cathide_index
        slist=scene.cathide_specific_panel_list
        sptoregister=[]
        sptounregister=[]
        nok=plist[idx].name

        #register panels
        for p in slist:
            if p.specific_panel_state==True:
                sptoregister.append(p.name)

        for p in sptoregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if hasattr(panel, 'bl_label'):
                                if panel.bl_space_type=="VIEW_3D":
                                    if panel.bl_region_type=="TOOLS":
                                        if panel.bl_category==nok:
                                            if panel.bl_label==p:
                                                if "bl_rna" not in panel.__dict__:
                                                    bpy.utils.register_class(panel)
        #unregister panels
        for p in slist:
            if p.specific_panel_state==False:
                sptounregister.append(p.name)

        for p in sptounregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if hasattr(panel, 'bl_label'):
                                if panel.bl_space_type=="VIEW_3D":
                                    if panel.bl_region_type=="TOOLS":
                                        if panel.bl_category==nok:
                                            if panel.bl_label==p:
                                                if "bl_rna" in panel.__dict__:
                                                    bpy.utils.unregister_class(panel)

        bpy.ops.cathide.refresh()

        info = 'Unselected Panels Hidden'
        self.report({'INFO'}, info)

        return {'FINISHED'} 

# add preset operator
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.panel_cathide_list

        #clear panel list
        for i in range(len(plist)-1,-1,-1):
            plist.remove(i)

        #declare category list
        catlistreg1=[]
        catlistreg2=[]
        catlistunreg1=[]
        catlistunreg2=[]
        catlistunreg3=[]
        #find category and append them in the list
        for panel in bpy.types.Panel.__subclasses__():
            if hasattr(panel, 'bl_space_type'):
                if hasattr(panel, 'bl_region_type'):
                    if hasattr(panel, 'bl_category'):
                        if panel.bl_space_type=="VIEW_3D":
                            if panel.bl_region_type=="TOOLS":
                                if "bl_rna" not in panel.__dict__:
                                    catlistunreg1.append(panel.bl_category)
                                elif "bl_rna" in panel.__dict__:
                                    catlistreg1.append(panel.bl_category)

        for c1 in list(set(catlistreg1)):
            catlistreg2.append(c1)

        for c1 in list(set(catlistunreg1)):
            catlistunreg2.append(c1)

        l1=Counter(catlistreg2)
        l2=Counter(catlistunreg2)
        diff=l2-l1

        for c in list(diff.elements()):
            catlistunreg3.append(c)

        for c2 in catlistreg2:
            newcat=plist.add()
            newcat.name=c2

        for c3 in catlistunreg3:
            newcat=plist.add()
            newcat.name=c3
            newcat.panelstate=False

        info = 'Panel List refreshed'
        self.report({'INFO'}, info)

        return {'FINISHED'}

# apply cathide configuration
项目:CatHide-Addon-for-Blender    作者:samytichadou    | 项目源码 | 文件源码
def execute(self, context):
        scene=bpy.context.scene
        plist=scene.panel_cathide_list
        toregister=[]
        tounregister=[]

        #register
        for p in plist:
            if p.panelstate==True:
                toregister.append(p.name)

        for p in toregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        if "bl_rna" not in panel.__dict__:
                                            bpy.utils.register_class(panel)
        #unregister
        for p in plist:
            if p.panelstate==False:
                tounregister.append(p.name)

        for p in tounregister:
            for panel in bpy.types.Panel.__subclasses__():
                if hasattr(panel, 'bl_space_type'):
                    if hasattr(panel, 'bl_region_type'):
                        if hasattr(panel, 'bl_category'):
                            if panel.bl_space_type=="VIEW_3D":
                                if panel.bl_region_type=="TOOLS":
                                    if panel.bl_category==p:
                                        if "bl_rna" in panel.__dict__:
                                            bpy.utils.unregister_class(panel)

        bpy.ops.cathide.refresh()

        info = 'Unselected Panels Hidden'
        self.report({'INFO'}, info)

        return {'FINISHED'} 

# add preset operator
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zs, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zs, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def _synch_childs(self, context, o, linked, childs):
        """
            sub synch childs nodes of linked object
        """
        # remove childs not found on source
        l_childs = self.get_childs_panels(context, linked)
        c_names = [c.data.name for c in childs]
        for c in l_childs:
            try:
                id = c_names.index(c.data.name)
            except:
                self.remove_handle(context, c)
                context.scene.objects.unlink(c)
                bpy.data.objects.remove(c, do_unlink=True)

        # children ordering may not be the same, so get the right l_childs order
        l_childs = self.get_childs_panels(context, linked)
        l_names = [c.data.name for c in l_childs]
        order = []
        for c in childs:
            try:
                id = l_names.index(c.data.name)
            except:
                id = -1
            order.append(id)

        # add missing childs and update other ones
        for i, child in enumerate(childs):
            if order[i] < 0:
                p = bpy.data.objects.new("Panel", child.data)
                context.scene.objects.link(p)
                p.lock_location[0] = True
                p.lock_location[1] = True
                p.lock_location[2] = True
                p.lock_rotation[1] = True
                p.lock_scale[0] = True
                p.lock_scale[1] = True
                p.lock_scale[2] = True
                p.parent = linked
                p.matrix_world = linked.matrix_world.copy()

            else:
                p = l_childs[order[i]]

            # update handle
            handle = self.find_handle(child)
            h = self.find_handle(p)
            if handle is not None:
                if h is None:
                    h = create_handle(context, p, handle.data)
                    MaterialUtils.add_handle_materials(h)
                h.location = handle.location.copy()
            elif h is not None:
                context.scene.objects.unlink(h)
                bpy.data.objects.remove(h, do_unlink=True)

            p.location = child.location.copy()
项目:archipack    作者:s-leger    | 项目源码 | 文件源码
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')
项目:archipack    作者:s-leger    | 项目源码 | 文件源码
def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
        n_subs = len(subs)
        if n_subs < 1:
            return
        f = len(verts)
        x0 = sub_offset_x - 0.5 * panel_x
        x1 = sub_offset_x + 0.5 * panel_x
        z0 = 0
        z1 = panel_z
        profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
        user_path_uv_v = []
        n_sections = n_subs - 1
        n, dz, zs, zl = subs[0]
        p0 = n.p
        v0 = n.v.normalized()
        for s, section in enumerate(subs):
            n, dz, zs, zl = section
            p1 = n.p
            if s < n_sections:
                v1 = subs[s + 1][0].v.normalized()
            dir = (v0 + v1).normalized()
            scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
            for p in profile:
                x, y = n.p + scale * p.x * dir
                z = zl + p.y + altitude
                verts.append((x, y, z))
            if s > 0:
                user_path_uv_v.append((p1 - p0).length)
            p0 = p1
            v0 = v1

        # build faces using Panel
        lofter = Lofter(
            # closed_shape, index, x, y, idmat
            True,
            [i for i in range(len(profile))],
            [p.x for p in profile],
            [p.y for p in profile],
            [idmat for i in range(len(profile))],
            closed_path=False,
            user_path_uv_v=user_path_uv_v,
            user_path_verts=n_subs
            )
        faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
        matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
        v = Vector((0, 0))
        uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')
项目:BetterBlender    作者:bobtherobot    | 项目源码 | 文件源码
def register():
    bpy.types.WindowManager.chosen_panel = bpy.props.StringProperty(update=get_category)
    bpy.utils.register_class(GroupNames)
    bpy.utils.register_class(ChangeCategoryPreferences)
    preferences = bpy.context.user_preferences.addons[__name__].preferences

    if bpy.context.user_preferences.addons[-1].module != __name__:
        cache = {}
        for k in preferences.tool_panels:
            cache[k.name] = k.idname, k.category, k.defa_cat
        # Register this addon last next startup
        module_name = __name__
        addons = bpy.context.user_preferences.addons

        while module_name in addons:
            addon = addons.get(module_name)
            if addon:
                addons.remove(addon)

        addon = addons.new()
        addon.module = module_name
        preferences = bpy.context.user_preferences.addons[module_name].preferences
        for k, v in cache.items():
            my_item = preferences.tool_panels.add()
            my_item.name = k
            my_item.idname = v[0]
            my_item.category = v[1]
            my_item.defa_cat = v[2]
        del cache

    #print(preferences.tool_panels)
    bpy.types.WindowManager.panel_category = bpy.props.StringProperty(
        name="Category",
        description="Choose a name for the category of the panel",
        default="My Category",
        update=update_category,
        )
    bpy.utils.register_class(VIEW3D_PT_change_category)

    for panel in bpy.types.Panel.__subclasses__():
        if hasattr(panel, 'bl_category'):
            name = panel.bl_category + ' (' + panel.bl_label + ', ' + panel.__name__ + ')'
            #if name not in preferences.tool_panels:
            for pref in preferences.tool_panels:
                if panel.__name__ == pref.idname:
                    if panel.bl_category != pref.category and\
                       panel.is_registered:
                        #print(name, ' to ', pref.category)
                        panel.bl_category = pref.category
                        bpy.utils.unregister_class(panel)
                        bpy.utils.register_class(panel)
                        break
                    break

            else:
                my_item = preferences.tool_panels.add()
                my_item.name = name
                my_item.idname = panel.__name__
                my_item.category = panel.bl_category
                my_item.defa_cat = panel.bl_category