mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-15 18:14:08 +00:00
bbim, bcf - add simple operator to quickly load ifc file from bcf header
Example - https://imgur.com/a/rieFwNI
This commit is contained in:
@@ -41,6 +41,7 @@ classes = (
|
||||
operator.EditBcfTopicName,
|
||||
operator.ExtractBcfFile,
|
||||
operator.LoadBcfComments,
|
||||
operator.LoadBcfHeaderIfcFile,
|
||||
operator.LoadBcfProject,
|
||||
operator.LoadBcfTopic,
|
||||
operator.LoadBcfTopics,
|
||||
|
||||
@@ -1239,6 +1239,30 @@ class SelectBcfDocumentReference(bpy.types.Operator):
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class LoadBcfHeaderIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.load_bcf_header_ifc_file"
|
||||
bl_label = "Load BCF Header IFC File"
|
||||
bl_description = (
|
||||
"Extract BCF Header IFC file and load it in current session."
|
||||
"\n\nWarning. Current IFC and BCF sessions won't be saved, BCF file will be reloaded (if it's saved on disk)"
|
||||
)
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||
assert bcfxml
|
||||
bcf_path = tool.Bcf.get_path()
|
||||
|
||||
topic = bcfxml.topics[context.scene.BCFProperties.active_topic.name]
|
||||
entity = topic.header.file[self.index]
|
||||
ifc_path = str(topic.extract_file(entity))
|
||||
bpy.ops.bim.load_project(filepath=ifc_path)
|
||||
if bcf_path:
|
||||
bpy.ops.bim.load_bcf_project(filepath=bcf_path)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ExtractBcfFile(bpy.types.Operator):
|
||||
bl_idname = "bim.extract_bcf_file"
|
||||
bl_label = "Extract BCF Header File"
|
||||
|
||||
@@ -140,6 +140,8 @@ class BIM_PT_bcf_metadata(Panel):
|
||||
if f.is_external:
|
||||
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
|
||||
else:
|
||||
op = row.operator("bim.load_bcf_header_ifc_file", icon="FILE_REFRESH", text="")
|
||||
op.index = index
|
||||
op = row.operator("bim.extract_bcf_file", icon="FILE_FOLDER", text="")
|
||||
op.index = index
|
||||
op.entity_type = "HEADER_FILE"
|
||||
|
||||
@@ -73,6 +73,11 @@ class Aggregate:
|
||||
def get_relating_object(cls, related_element): pass
|
||||
|
||||
|
||||
@interface
|
||||
class Bcf:
|
||||
pass
|
||||
|
||||
|
||||
@interface
|
||||
class Blender:
|
||||
def activate_camera(cls, obj): pass
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from bonsai.tool.aggregate import Aggregate
|
||||
from bonsai.tool.bcf import Bcf
|
||||
from bonsai.tool.blender import Blender
|
||||
from bonsai.tool.boundary import Boundary
|
||||
from bonsai.tool.brick import Brick
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Bonsai - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of Bonsai.
|
||||
#
|
||||
# Bonsai is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Bonsai is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
import bpy
|
||||
from typing import Any, Union, Optional
|
||||
|
||||
|
||||
class Bcf(bonsai.core.tool.Bcf):
|
||||
@classmethod
|
||||
def get_path(cls) -> str:
|
||||
return bpy.context.scene.BCFProperties.bcf_file
|
||||
Reference in New Issue
Block a user