mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Add button and operator to uninstall add-on
This commit is contained in:
@@ -6,8 +6,7 @@ bl_info = {
|
||||
"blender": (2, 80, 0),
|
||||
"version": (0, 0, 999999),
|
||||
"location": "File > Export, File > Import, Scene / Object / Material / Mesh Properties",
|
||||
"tracker_url": "https://sourceforge.net/p/ifcopenshell/"
|
||||
"_list/tickets?source=navbar",
|
||||
"tracker_url": "https://github.com/IfcOpenShell/IfcOpenShell/issues",
|
||||
"category": "Import-Export"
|
||||
}
|
||||
|
||||
@@ -103,6 +102,7 @@ if bpy is not None:
|
||||
operator.ExecuteIfcDiff,
|
||||
operator.AssignContext,
|
||||
operator.SetViewPreset1,
|
||||
operator.Uninstall,
|
||||
prop.BcfTopic,
|
||||
prop.Subcontext,
|
||||
prop.BIMProperties,
|
||||
@@ -137,6 +137,7 @@ if bpy is not None:
|
||||
ui.BIM_PT_object,
|
||||
ui.BIM_PT_camera,
|
||||
ui.BIM_UL_topics,
|
||||
ui.BIM_ADDON_preferences,
|
||||
)
|
||||
|
||||
def menu_func_export(self, context):
|
||||
@@ -183,7 +184,7 @@ if bpy is not None:
|
||||
del(bpy.types.Collection.BIMObjectProperties)
|
||||
del(bpy.types.Material.BIMMaterialProperties)
|
||||
del(bpy.types.Mesh.BIMMeshProperties)
|
||||
del(bpy.types.Mesh.BIMCameraProperties)
|
||||
del(bpy.types.Camera.BIMCameraProperties)
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
@@ -1314,3 +1314,41 @@ class SetViewPreset1(bpy.types.Operator):
|
||||
bpy.context.scene.display.shading.curvature_valley_factor = 1
|
||||
bpy.context.scene.view_settings.view_transform = 'Standard'
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class Uninstall(bpy.types.Operator):
|
||||
bl_idname = 'bim.uninstall'
|
||||
bl_label = 'Uninstall BlenderBIM'
|
||||
|
||||
def execute(self, context):
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
addon_dir = os.path.join(cwd, '..')
|
||||
files = ['ifcdiff.py', 'ordered_set.py', 'pyparsing.py', 'six.py']
|
||||
directories = ['OCC', 'bcfplugin', 'dateutil', 'deepdiff',
|
||||
'elementpath', 'ifcopenshell', 'jsonpickle', 'lib', 'pystache',
|
||||
'pytz', 'svgwrite', 'xmlschema']
|
||||
|
||||
for f in files:
|
||||
path = os.path.join(addon_dir, f)
|
||||
if os.path.isfile(path):
|
||||
os.remove(path)
|
||||
|
||||
lib_dir = os.path.join(cwd, '..', 'lib')
|
||||
lib_files = glob.glob(os.path.join(lib_dir, '..', '..', '..', 'lib*.so*'))
|
||||
|
||||
for lib_file in lib_files:
|
||||
try:
|
||||
os.remove(lib_file)
|
||||
except:
|
||||
print('Error while deleting file: ', lib_file)
|
||||
shutil.rmtree(os.path.join(lib_dir, '..', '..', '..', 'oce-0.17'), ignore_errors=True)
|
||||
|
||||
for directory in directories:
|
||||
path = os.path.join(addon_dir, directory)
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
bpy.ops.preferences.addon_remove(module='blenderbim')
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -733,3 +733,12 @@ class BIM_UL_topics(bpy.types.UIList):
|
||||
layout.prop(item, 'name', text='', emboss=False)
|
||||
else:
|
||||
layout.label(text="", translate=False)
|
||||
|
||||
|
||||
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
bl_idname = __package__
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
row.operator('bim.uninstall')
|
||||
|
||||
Reference in New Issue
Block a user