Skip to content
Snippets Groups Projects
mesh_snap_utilities_line.py 43.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
    # Define Panel classes for updating
    panels = (
            PanelSnapUtilities,
            )
    
    
    
        message = "Snap Utilities Line: Updating Panel locations has failed"
    
        addon_prefs = context.user_preferences.addons[__name__].preferences
    
                if addon_prefs.category != panel.bl_category:
                    if "bl_rna" in panel.__dict__:
                        bpy.utils.unregister_class(panel)
    
                    panel.bl_category = addon_prefs.category
                    bpy.utils.register_class(panel)
    
    
        except Exception as e:
            print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
    
    
    class SnapAddonPreferences(AddonPreferences):
    
        # this must match the addon name, use '__package__'
        # when defining this in a submodule of a python package.
        bl_idname = __name__
    
    
                description="Intersects created line with the existing edges, "
                            "even if the lines do not intersect",
                default=True
                )
        create_new_obj = BoolProperty(
    
                description="If have not a active object, or the active object "
                            "is not in edit mode, it creates a new object",
                default=False
                )
        create_face = BoolProperty(
    
                description="Create faces defined by enclosed edges",
                default=False
                )
        outer_verts = BoolProperty(
    
                description="The vertices of the objects are not activated also snapped",
                default=True
                )
        expand_snap_settings = BoolProperty(
    
                name="Expand",
                description="Expand, to display the settings",
    
                default=False
                )
        expand_color_settings = BoolProperty(
    
                description="Expand, to display the color settings",
                default=False
                )
        increments_grid = BoolProperty(
    
                name="Increments of Grid",
                description="Snap to increments of grid",
    
                default=False
                )
        category = StringProperty(
    
                name="Category",
                description="Choose a name for the category of the panel",
    
                default="Tools",
    
                update=update_panel
                )
        incremental = FloatProperty(
    
                name="Incremental",
                description="Snap in defined increments",
                default=0,
                min=0,
                step=1,
    
                precision=3
                )
        relative_scale = FloatProperty(
    
                description="Value that divides the global scale",
    
                precision=3
                )
        out_color = FloatVectorProperty(
                name="OUT",
                default=(0.0, 0.0, 0.0, 0.5),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        face_color = FloatVectorProperty(
                name="FACE",
                default=(1.0, 0.8, 0.0, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        edge_color = FloatVectorProperty(
                name="EDGE",
                default=(0.0, 0.8, 1.0, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        vert_color = FloatVectorProperty(
                name="VERT",
                default=(1.0, 0.5, 0.0, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        center_color = FloatVectorProperty(
                name="CENTER",
                default=(1.0, 0.0, 1.0, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        perpendicular_color = FloatVectorProperty(
                name="PERPENDICULAR",
                default=(0.1, 0.5, 0.5, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
        constrain_shift_color = FloatVectorProperty(
                name="SHIFT CONSTRAIN",
                default=(0.8, 0.5, 0.4, 1.0),
                size=4,
                subtype="COLOR",
                min=0, max=1
                )
    
    
        def draw(self, context):
            layout = self.layout
    
            icon = "TRIA_DOWN" if self.expand_color_settings else "TRIA_RIGHT"
    
            box.prop(self, "expand_color_settings", icon=icon, toggle=True, emboss=False)
    
            if self.expand_color_settings:
                split = box.split()
    
                col = split.column()
                col.prop(self, "out_color")
                col.prop(self, "constrain_shift_color")
                col = split.column()
                col.prop(self, "face_color")
                col.prop(self, "center_color")
                col = split.column()
                col.prop(self, "edge_color")
                col.prop(self, "perpendicular_color")
                col = split.column()
                col.prop(self, "vert_color")
    
            col = row.column(align=True)
            box = col.box()
            box.label(text="Snap Items:")
            box.prop(self, "incremental")
    
            box.prop(self, "outer_verts")
            box.prop(self, "increments_grid")
    
                box.prop(self, "relative_scale")
            else:
                box.separator()
                box.separator()
    
            col = row.column(align=True)
            box = col.box()
            box.label(text="Line Tool:")
    
            box.prop(self, "intersect")
            box.prop(self, "create_face")
            box.prop(self, "create_new_obj")
    
            col.label(text="Tab Category:")
            col.prop(self, "category", text="")
    
    
    
    def register():
        bpy.utils.register_class(SnapAddonPreferences)
        bpy.utils.register_class(SnapUtilitiesLine)
    
        bpy.utils.register_class(PanelSnapUtilities)
    
        update_panel(None, bpy.context)
    
    
    def unregister():
        bpy.utils.unregister_class(PanelSnapUtilities)
        bpy.utils.unregister_class(SnapUtilitiesLine)
        bpy.utils.unregister_class(SnapAddonPreferences)
    
    
    if __name__ == "__main__":
        __name__ = "mesh_snap_utilities_line"
        register()