mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Separate project templates and libraries and provide dropdown to built-in libraries to aid discoverability.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -35,6 +35,7 @@ class ProjectData:
|
|||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"export_schema": cls.get_export_schema(),
|
"export_schema": cls.get_export_schema(),
|
||||||
|
"library_file": cls.library_file(),
|
||||||
"template_file": cls.template_file(),
|
"template_file": cls.template_file(),
|
||||||
"last_saved": cls.last_saved(),
|
"last_saved": cls.last_saved(),
|
||||||
}
|
}
|
||||||
@@ -45,10 +46,17 @@ class ProjectData:
|
|||||||
return [(s, s, "") for s in IfcStore.schema_identifiers]
|
return [(s, s, "") for s in IfcStore.schema_identifiers]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def template_file(cls):
|
def library_file(cls):
|
||||||
files = os.listdir(os.path.join(bpy.context.scene.BIMProperties.data_dir, "libraries"))
|
files = os.listdir(os.path.join(bpy.context.scene.BIMProperties.data_dir, "libraries"))
|
||||||
|
results = [("0", "Custom Library", "")]
|
||||||
|
results.extend([(f, os.path.splitext(f)[0], "") for f in files if ".ifc" in f])
|
||||||
|
return results
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def template_file(cls):
|
||||||
|
files = os.listdir(os.path.join(bpy.context.scene.BIMProperties.data_dir, "templates", "projects"))
|
||||||
results = [("0", "Blank Project", "")]
|
results = [("0", "Blank Project", "")]
|
||||||
results.extend([(f, f.replace(".ifc", ""), "") for f in files if ".ifc" in f])
|
results.extend([(f, os.path.splitext(f)[0], "") for f in files if ".ifc" in f])
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell.util.placement
|
import ifcopenshell.util.placement
|
||||||
from blenderbim.bim.module.project.data import ProjectData
|
from blenderbim.bim.module.project.data import ProjectData
|
||||||
@@ -45,6 +46,19 @@ def get_template_file(self, context):
|
|||||||
return ProjectData.data["template_file"]
|
return ProjectData.data["template_file"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_library_file(self, context):
|
||||||
|
if not ProjectData.is_loaded:
|
||||||
|
ProjectData.load()
|
||||||
|
return ProjectData.data["library_file"]
|
||||||
|
|
||||||
|
|
||||||
|
def update_library_file(self, context):
|
||||||
|
if self.library_file != "0":
|
||||||
|
bpy.ops.bim.select_library_file(
|
||||||
|
filepath=os.path.join(bpy.context.scene.BIMProperties.data_dir, "libraries", self.library_file)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_filter_mode(self, context):
|
def update_filter_mode(self, context):
|
||||||
self.filter_categories.clear()
|
self.filter_categories.clear()
|
||||||
if self.filter_mode == "NONE":
|
if self.filter_mode == "NONE":
|
||||||
@@ -169,6 +183,7 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
active_link_index: IntProperty(name="Active Link Index")
|
active_link_index: IntProperty(name="Active Link Index")
|
||||||
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
|
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
|
||||||
template_file: EnumProperty(items=get_template_file, name="Template File")
|
template_file: EnumProperty(items=get_template_file, name="Template File")
|
||||||
|
library_file: EnumProperty(items=get_library_file, name="Library File", update=update_library_file)
|
||||||
use_relative_project_path: BoolProperty(name="Use Relative Project Path", default=False)
|
use_relative_project_path: BoolProperty(name="Use Relative Project Path", default=False)
|
||||||
queried_obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
queried_obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||||
clipping_planes: bpy.props.CollectionProperty(type=ObjProperty)
|
clipping_planes: bpy.props.CollectionProperty(type=ObjProperty)
|
||||||
|
|||||||
@@ -255,12 +255,20 @@ class BIM_PT_project_library(Panel):
|
|||||||
self.layout.use_property_split = True
|
self.layout.use_property_split = True
|
||||||
self.props = context.scene.BIMProjectProperties
|
self.props = context.scene.BIMProjectProperties
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=IfcStore.library_path or "No Library Loaded", icon="ASSET_MANAGER")
|
row.prop(self.props, "library_file", text="")
|
||||||
|
if self.props.library_file == "0":
|
||||||
|
row.operator("bim.select_library_file", icon="FILE_FOLDER", text="")
|
||||||
|
row = self.layout.row(align=True)
|
||||||
if IfcStore.library_file:
|
if IfcStore.library_file:
|
||||||
row.label(text=IfcStore.library_file.schema)
|
row.label(
|
||||||
|
text=os.path.splitext(os.path.basename(IfcStore.library_path))[0]
|
||||||
|
+ f" - {IfcStore.library_file.schema}",
|
||||||
|
icon="ASSET_MANAGER",
|
||||||
|
)
|
||||||
row.operator("bim.append_library_element_by_query", text="", icon="APPEND_BLEND")
|
row.operator("bim.append_library_element_by_query", text="", icon="APPEND_BLEND")
|
||||||
row.operator("bim.save_library_file", text="", icon="EXPORT")
|
row.operator("bim.save_library_file", text="", icon="EXPORT")
|
||||||
row.operator("bim.select_library_file", icon="FILE_FOLDER", text="")
|
else:
|
||||||
|
row.label(text="No Library Loaded", icon="ASSET_MANAGER")
|
||||||
if IfcStore.library_file:
|
if IfcStore.library_file:
|
||||||
self.draw_library_ul()
|
self.draw_library_ul()
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Project(blenderbim.core.tool.Project):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def append_all_types_from_template(cls, template):
|
def append_all_types_from_template(cls, template):
|
||||||
# TODO refactor
|
# TODO refactor
|
||||||
filepath = os.path.join(bpy.context.scene.BIMProperties.data_dir, "libraries", template)
|
filepath = os.path.join(bpy.context.scene.BIMProperties.data_dir, "templates", "projects", template)
|
||||||
bpy.ops.bim.select_library_file(filepath=filepath)
|
bpy.ops.bim.select_library_file(filepath=filepath)
|
||||||
if IfcStore.library_file.schema != tool.Ifc.get().schema:
|
if IfcStore.library_file.schema != tool.Ifc.get().schema:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user