mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 21:12:07 +00:00
WIP you can now start a fresh project with partial editing support. See #1222.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import bpy
|
||||
from . import ui, operator
|
||||
|
||||
classes = (
|
||||
operator.CreateProject,
|
||||
ui.BIM_PT_project,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
pass
|
||||
|
||||
|
||||
def unregister():
|
||||
pass
|
||||
@@ -0,0 +1,25 @@
|
||||
import datetime
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, settings=None):
|
||||
self.settings = {"version": "IFC4"}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
self.file = ifcopenshell.file(schema=self.settings["version"])
|
||||
# TODO: add all metadata, pending bug #747
|
||||
self.file.wrapped_data.header.file_name.name = "/dev/null" # Hehehe
|
||||
self.file.wrapped_data.header.file_name.time_stamp = (
|
||||
datetime.datetime.utcnow()
|
||||
.replace(tzinfo=datetime.timezone.utc)
|
||||
.astimezone()
|
||||
.replace(microsecond=0)
|
||||
.isoformat()
|
||||
)
|
||||
self.file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
|
||||
self.file.wrapped_data.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
|
||||
self.file.wrapped_data.header.file_name.authorization = "Nobody"
|
||||
return self.file
|
||||
@@ -0,0 +1,68 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import blenderbim.bim.module.project.create_file as create_file
|
||||
import blenderbim.bim.module.context.add_context as add_context
|
||||
import blenderbim.bim.module.root.create_product as create_product
|
||||
import blenderbim.bim.module.aggregate.assign_object as assign_object
|
||||
import bpy
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
# from blenderbim.bim.module.project.data import Data
|
||||
|
||||
|
||||
class CreateProject(bpy.types.Operator):
|
||||
bl_idname = "bim.create_project"
|
||||
bl_label = "Create Project"
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
if self.file:
|
||||
return {"FINISHED"}
|
||||
|
||||
IfcStore.file = create_file.Usecase({"version": bpy.context.scene.BIMProperties.export_schema}).execute()
|
||||
self.file = IfcStore.get_file()
|
||||
|
||||
project = bpy.data.collections.new("My Project")
|
||||
site = bpy.data.collections.new("My Site")
|
||||
building = bpy.data.collections.new("My Building")
|
||||
building_storey = bpy.data.collections.new("Ground Floor")
|
||||
|
||||
project_obj = bpy.data.objects.new("My Project", None)
|
||||
site_obj = bpy.data.objects.new("My Site", None)
|
||||
building_obj = bpy.data.objects.new("My Building", None)
|
||||
building_storey_obj = bpy.data.objects.new("Ground Floor", None)
|
||||
|
||||
bpy.context.scene.collection.children.link(project)
|
||||
project.children.link(site)
|
||||
site.children.link(building)
|
||||
building.children.link(building_storey)
|
||||
|
||||
project.objects.link(project_obj)
|
||||
site.objects.link(site_obj)
|
||||
building.objects.link(building_obj)
|
||||
building_storey.objects.link(building_storey_obj)
|
||||
|
||||
bpy.ops.bim.assign_class(obj=project_obj.name, ifc_class="IfcProject")
|
||||
bpy.ops.bim.assign_unit()
|
||||
bpy.ops.bim.add_subcontext(context="Model")
|
||||
bpy.ops.bim.add_subcontext(context="Model", subcontext="Body", target_view="MODEL_VIEW")
|
||||
bpy.ops.bim.add_subcontext(context="Model", subcontext="Box", target_view="MODEL_VIEW")
|
||||
bpy.ops.bim.add_subcontext(context="Plan")
|
||||
bpy.ops.bim.add_subcontext(context="Plan", subcontext="Annotation", target_view="PLAN_VIEW")
|
||||
bpy.ops.bim.assign_class(obj=site_obj.name, ifc_class="IfcSite")
|
||||
bpy.ops.bim.assign_class(obj=building_obj.name, ifc_class="IfcBuilding")
|
||||
bpy.ops.bim.assign_class(obj=building_storey_obj.name, ifc_class="IfcBuildingStorey")
|
||||
bpy.ops.bim.assign_object(related_object=site_obj.name, relating_object=project_obj.name)
|
||||
bpy.ops.bim.assign_object(related_object=building_obj.name, relating_object=site_obj.name)
|
||||
bpy.ops.bim.assign_object(related_object=building_storey_obj.name, relating_object=building_obj.name)
|
||||
# Data.load()
|
||||
return {"FINISHED"}
|
||||
|
||||
def assign_object(self, product, relating_object):
|
||||
assign_object.Usecase(
|
||||
self.file,
|
||||
{
|
||||
"product": product,
|
||||
"relating_object": relating_object,
|
||||
},
|
||||
).execute()
|
||||
@@ -0,0 +1,31 @@
|
||||
from bpy.types import Panel
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_PT_project(Panel):
|
||||
bl_label = "IFC Project"
|
||||
bl_idname = "BIM_PT_project"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
|
||||
def draw(self, context):
|
||||
self.layout.use_property_decorate = False
|
||||
self.layout.use_property_split = True
|
||||
self.file = IfcStore.get_file()
|
||||
props = context.scene.BIMProperties
|
||||
if self.file:
|
||||
pass
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.prop(props, "export_schema")
|
||||
row = self.layout.row()
|
||||
row.prop(context.scene.unit_settings, "system")
|
||||
row = self.layout.row()
|
||||
row.prop(context.scene.unit_settings, "length_unit")
|
||||
row = self.layout.row()
|
||||
row.prop(props, "area_unit", text="Area Unit")
|
||||
row = self.layout.row()
|
||||
row.prop(props, "volume_unit", text="Volume Unit")
|
||||
row = self.layout.row()
|
||||
row.operator("bim.create_project")
|
||||
Reference in New Issue
Block a user