2020-04-07 12:02:44 +10:00
|
|
|
# Check if we are running in Blender before loading, to allow for multiprocessing
|
|
|
|
|
import sys
|
2020-11-01 20:08:48 +07:00
|
|
|
|
|
|
|
|
bpy = sys.modules.get("bpy")
|
2020-04-07 12:02:44 +10:00
|
|
|
|
|
|
|
|
if bpy is not None:
|
|
|
|
|
import bpy
|
2021-01-12 15:12:53 +11:00
|
|
|
import importlib
|
2020-04-07 12:02:44 +10:00
|
|
|
from . import ui, prop, operator
|
|
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
modules = {
|
2021-01-26 16:07:35 +11:00
|
|
|
"project": None,
|
|
|
|
|
"search": None,
|
2021-01-12 15:12:53 +11:00
|
|
|
"bcf": None,
|
2021-01-26 16:07:35 +11:00
|
|
|
"root": None,
|
|
|
|
|
"unit": None,
|
|
|
|
|
"georeference": None,
|
2021-01-12 15:12:53 +11:00
|
|
|
"context": None,
|
2021-01-26 16:07:35 +11:00
|
|
|
"attribute": None,
|
|
|
|
|
"type": None,
|
|
|
|
|
"spatial": None,
|
|
|
|
|
"void": None,
|
|
|
|
|
"aggregate": None,
|
2021-01-12 15:12:53 +11:00
|
|
|
"geometry": None,
|
2021-01-26 16:07:35 +11:00
|
|
|
"cobie": None,
|
2021-01-17 12:46:35 +11:00
|
|
|
"material": None,
|
2021-01-26 16:07:35 +11:00
|
|
|
"style": None,
|
|
|
|
|
"layer": None,
|
2021-01-12 15:12:53 +11:00
|
|
|
"model": None,
|
|
|
|
|
"owner": None,
|
|
|
|
|
"pset": None,
|
2021-01-23 18:01:29 +11:00
|
|
|
"qto": None,
|
2021-01-26 16:07:35 +11:00
|
|
|
"classification": None,
|
|
|
|
|
"constraint": None,
|
|
|
|
|
"document": None,
|
|
|
|
|
"pset_template": None,
|
|
|
|
|
"clash": None,
|
|
|
|
|
"csv": None,
|
|
|
|
|
"bimtester": None,
|
|
|
|
|
"diff": None,
|
|
|
|
|
"patch": None,
|
|
|
|
|
"covetool": None,
|
|
|
|
|
"debug": None,
|
2021-01-12 15:12:53 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for name in modules.keys():
|
|
|
|
|
modules[name] = importlib.import_module(f"blenderbim.bim.module.{name}")
|
|
|
|
|
|
2020-12-29 13:49:53 +11:00
|
|
|
classes = [
|
2020-12-18 16:28:17 +11:00
|
|
|
operator.OpenUri,
|
2020-04-07 12:02:44 +10:00
|
|
|
operator.SelectDataDir,
|
|
|
|
|
operator.SelectSchemaDir,
|
|
|
|
|
operator.SelectIfcFile,
|
|
|
|
|
operator.ExportIFC,
|
|
|
|
|
operator.ImportIFC,
|
|
|
|
|
operator.SelectExternalMaterialDir,
|
|
|
|
|
operator.AddSweptSolid,
|
|
|
|
|
operator.RemoveSweptSolid,
|
|
|
|
|
operator.AssignSweptSolidOuterCurve,
|
|
|
|
|
operator.SelectSweptSolidOuterCurve,
|
|
|
|
|
operator.AddSweptSolidInnerCurve,
|
|
|
|
|
operator.SelectSweptSolidInnerCurves,
|
|
|
|
|
operator.AssignSweptSolidExtrusion,
|
|
|
|
|
operator.SelectSweptSolidExtrusion,
|
|
|
|
|
operator.FetchExternalMaterial,
|
|
|
|
|
operator.FetchObjectPassport,
|
|
|
|
|
operator.CutSection,
|
2020-08-16 11:54:05 +10:00
|
|
|
operator.AddSheet,
|
2020-04-07 12:02:44 +10:00
|
|
|
operator.OpenSheet,
|
2020-08-16 11:54:05 +10:00
|
|
|
operator.AddDrawingToSheet,
|
2020-04-07 12:02:44 +10:00
|
|
|
operator.CreateSheets,
|
|
|
|
|
operator.OpenView,
|
2020-12-29 06:00:49 +07:00
|
|
|
operator.OpenViewCamera,
|
2020-04-07 12:02:44 +10:00
|
|
|
operator.ActivateView,
|
|
|
|
|
operator.OpenUpstream,
|
2020-04-25 16:21:15 +10:00
|
|
|
operator.AddSectionPlane,
|
2020-04-25 19:09:34 +10:00
|
|
|
operator.RemoveSectionPlane,
|
2020-04-28 14:52:04 +10:00
|
|
|
operator.ReloadIfcFile,
|
2020-05-02 17:33:16 +10:00
|
|
|
operator.AddIfcFile,
|
|
|
|
|
operator.RemoveIfcFile,
|
|
|
|
|
operator.SelectDocIfcFile,
|
2020-05-03 15:41:05 +10:00
|
|
|
operator.AddAnnotation,
|
2020-08-29 18:56:23 +10:00
|
|
|
operator.GenerateReferences,
|
2020-05-03 19:54:27 +10:00
|
|
|
operator.ResizeText,
|
2020-05-04 12:20:34 +10:00
|
|
|
operator.AddVariable,
|
|
|
|
|
operator.RemoveVariable,
|
2020-05-07 09:36:38 +10:00
|
|
|
operator.PropagateTextData,
|
2020-08-12 19:59:30 +10:00
|
|
|
operator.SetOverrideColour,
|
2020-08-13 20:17:51 +10:00
|
|
|
operator.AddDrawing,
|
|
|
|
|
operator.RemoveDrawing,
|
2020-08-12 21:50:57 +10:00
|
|
|
operator.AddDrawingStyle,
|
|
|
|
|
operator.RemoveDrawingStyle,
|
|
|
|
|
operator.SaveDrawingStyle,
|
|
|
|
|
operator.ActivateDrawingStyle,
|
2020-08-15 09:45:20 +10:00
|
|
|
operator.EditVectorStyle,
|
2020-08-16 11:54:05 +10:00
|
|
|
operator.RemoveSheet,
|
2020-08-17 21:43:33 +10:00
|
|
|
operator.AddSchedule,
|
|
|
|
|
operator.RemoveSchedule,
|
|
|
|
|
operator.SelectScheduleFile,
|
2020-08-17 22:10:06 +10:00
|
|
|
operator.BuildSchedule,
|
2020-08-18 10:04:19 +10:00
|
|
|
operator.AddScheduleToSheet,
|
2020-09-01 22:26:57 +10:00
|
|
|
operator.SetViewportShadowFromSun,
|
2020-09-02 21:51:58 +10:00
|
|
|
operator.AddDrawingStyleAttribute,
|
|
|
|
|
operator.RemoveDrawingStyleAttribute,
|
2020-09-03 19:24:55 +10:00
|
|
|
operator.CopyPropertyToSelection,
|
2020-11-22 09:29:33 +11:00
|
|
|
operator.CopyAttributeToSelection,
|
2020-09-07 17:47:19 +10:00
|
|
|
operator.RefreshDrawingList,
|
2020-12-10 13:50:43 +11:00
|
|
|
operator.CleanWireframes,
|
2020-12-10 13:52:29 +11:00
|
|
|
operator.LinkIfc,
|
2020-12-21 18:26:39 +11:00
|
|
|
operator.SnapSpacesTogether,
|
2020-12-26 23:25:39 +07:00
|
|
|
operator.CopyGrid,
|
2021-01-12 09:32:04 +07:00
|
|
|
operator.AddSectionsAnnotations,
|
2020-04-23 16:05:06 +10:00
|
|
|
prop.StrProperty,
|
2020-11-09 19:15:23 +11:00
|
|
|
prop.Attribute,
|
2020-05-04 12:20:34 +10:00
|
|
|
prop.Variable,
|
2020-08-13 20:17:51 +10:00
|
|
|
prop.Drawing,
|
2020-08-17 21:43:33 +10:00
|
|
|
prop.Schedule,
|
2020-08-12 21:50:57 +10:00
|
|
|
prop.DrawingStyle,
|
2020-08-16 11:54:05 +10:00
|
|
|
prop.Sheet,
|
2020-04-07 12:02:44 +10:00
|
|
|
prop.BIMProperties,
|
|
|
|
|
prop.DocProperties,
|
2020-09-17 17:28:17 +10:00
|
|
|
prop.IfcParameter,
|
2020-04-07 12:02:44 +10:00
|
|
|
prop.BoundaryCondition,
|
|
|
|
|
prop.PsetQto,
|
|
|
|
|
prop.GlobalId,
|
2020-06-11 10:52:00 +10:00
|
|
|
prop.RepresentationItem,
|
2020-04-07 12:02:44 +10:00
|
|
|
prop.BIMObjectProperties,
|
|
|
|
|
prop.BIMMaterialProperties,
|
|
|
|
|
prop.SweptSolid,
|
2020-11-26 21:31:42 +11:00
|
|
|
prop.ItemSlotMap,
|
2020-04-07 12:02:44 +10:00
|
|
|
prop.BIMMeshProperties,
|
|
|
|
|
prop.BIMCameraProperties,
|
2020-05-03 19:54:27 +10:00
|
|
|
prop.BIMTextProperties,
|
2020-04-25 16:21:15 +10:00
|
|
|
ui.BIM_PT_section_plane,
|
2020-08-13 20:17:51 +10:00
|
|
|
ui.BIM_PT_drawings,
|
2020-08-17 21:43:33 +10:00
|
|
|
ui.BIM_PT_schedules,
|
2020-08-13 20:17:51 +10:00
|
|
|
ui.BIM_PT_sheets,
|
2020-04-07 12:02:44 +10:00
|
|
|
ui.BIM_PT_camera,
|
2020-05-03 19:54:27 +10:00
|
|
|
ui.BIM_PT_text,
|
2020-08-29 11:02:43 +10:00
|
|
|
ui.BIM_PT_annotation_utilities,
|
2020-08-12 19:59:30 +10:00
|
|
|
ui.BIM_PT_misc_utilities,
|
2020-07-09 20:46:50 +10:00
|
|
|
ui.BIM_UL_generic,
|
2020-12-29 10:03:57 +11:00
|
|
|
ui.BIM_UL_drawinglist,
|
2020-04-07 12:02:44 +10:00
|
|
|
ui.BIM_UL_topics,
|
|
|
|
|
ui.BIM_ADDON_preferences,
|
2020-12-29 13:49:53 +11:00
|
|
|
]
|
|
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
for module in modules.values():
|
|
|
|
|
classes.extend(module.classes)
|
|
|
|
|
|
2020-04-07 12:02:44 +10:00
|
|
|
def menu_func_export(self, context):
|
2020-11-01 20:08:48 +07:00
|
|
|
self.layout.operator(operator.ExportIFC.bl_idname, text="Industry Foundation Classes (.ifc/.ifczip/.ifcjson)")
|
2020-04-07 12:02:44 +10:00
|
|
|
|
|
|
|
|
def menu_func_import(self, context):
|
2020-11-01 20:08:48 +07:00
|
|
|
self.layout.operator(operator.ImportIFC.bl_idname, text="Industry Foundation Classes (.ifc/.ifczip/.ifcxml)")
|
2020-04-07 12:02:44 +10:00
|
|
|
|
|
|
|
|
def on_register(scene):
|
|
|
|
|
prop.setDefaultProperties(scene)
|
2020-09-09 18:49:27 +10:00
|
|
|
bpy.app.handlers.depsgraph_update_post.remove(on_register)
|
2020-04-07 12:02:44 +10:00
|
|
|
|
|
|
|
|
def register():
|
|
|
|
|
for cls in classes:
|
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
|
bpy.app.handlers.depsgraph_update_post.append(on_register)
|
|
|
|
|
bpy.app.handlers.load_post.append(prop.setDefaultProperties)
|
|
|
|
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
|
|
|
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
|
|
|
|
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties)
|
|
|
|
|
bpy.types.Scene.DocProperties = bpy.props.PointerProperty(type=prop.DocProperties)
|
|
|
|
|
bpy.types.Object.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties)
|
2021-01-17 21:07:01 +11:00
|
|
|
bpy.types.Material.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties)
|
2021-01-17 12:46:35 +11:00
|
|
|
bpy.types.Collection.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties) # Check if we need this
|
2020-04-07 12:02:44 +10:00
|
|
|
bpy.types.Material.BIMMaterialProperties = bpy.props.PointerProperty(type=prop.BIMMaterialProperties)
|
|
|
|
|
bpy.types.Mesh.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties)
|
|
|
|
|
bpy.types.Camera.BIMCameraProperties = bpy.props.PointerProperty(type=prop.BIMCameraProperties)
|
2020-05-03 19:54:27 +10:00
|
|
|
bpy.types.TextCurve.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties)
|
2020-08-09 13:09:29 +10:00
|
|
|
bpy.types.SCENE_PT_unit.append(ui.ifc_units)
|
2021-01-12 15:12:53 +11:00
|
|
|
|
|
|
|
|
for module in modules.values():
|
|
|
|
|
module.register()
|
|
|
|
|
|
2020-08-29 10:28:34 +10:00
|
|
|
bpy.app.handlers.depsgraph_update_pre.append(operator.depsgraph_update_pre_handler)
|
2021-01-06 04:01:03 +07:00
|
|
|
bpy.app.handlers.load_post.append(prop.toggleDecorationsOnLoad)
|
2020-04-07 12:02:44 +10:00
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
|
for cls in reversed(classes):
|
|
|
|
|
bpy.utils.unregister_class(cls)
|
|
|
|
|
bpy.app.handlers.load_post.remove(prop.setDefaultProperties)
|
|
|
|
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
|
|
|
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
2020-11-01 20:08:48 +07:00
|
|
|
del bpy.types.Scene.BIMProperties
|
|
|
|
|
del bpy.types.Scene.DocProperties
|
|
|
|
|
del bpy.types.Object.BIMObjectProperties
|
2021-01-17 21:07:01 +11:00
|
|
|
del bpy.types.Material.BIMObjectProperties
|
2021-01-17 12:46:35 +11:00
|
|
|
del bpy.types.Collection.BIMObjectProperties # Check if we need this
|
2020-11-01 20:08:48 +07:00
|
|
|
del bpy.types.Material.BIMMaterialProperties
|
|
|
|
|
del bpy.types.Mesh.BIMMeshProperties
|
|
|
|
|
del bpy.types.Camera.BIMCameraProperties
|
|
|
|
|
del bpy.types.TextCurve.BIMTextProperties
|
2020-08-09 13:09:29 +10:00
|
|
|
bpy.types.SCENE_PT_unit.remove(ui.ifc_units)
|
2021-01-12 15:12:53 +11:00
|
|
|
|
|
|
|
|
for module in reversed(list(modules.values())):
|
|
|
|
|
module.unregister()
|
|
|
|
|
|
2020-08-29 10:28:34 +10:00
|
|
|
bpy.app.handlers.depsgraph_update_pre.remove(operator.depsgraph_update_pre_handler)
|