Elementary fixes to the BCF module just so that things load (but lots are still broken)

This commit is contained in:
Dion Moult
2022-11-09 23:35:35 +11:00
parent 33b5b350ef
commit 5e80db500d
3 changed files with 31 additions and 21 deletions
+7
View File
@@ -312,6 +312,13 @@ endif
cp -r dist/working/xmlschema-2.0.2/xmlschema dist/blenderbim/libs/site/packages/ cp -r dist/working/xmlschema-2.0.2/xmlschema dist/blenderbim/libs/site/packages/
rm -rf dist/working rm -rf dist/working
# Required by bcf
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/ad/c7/17c9d16320d8e2cfdb27d2fd298b5e8f7a3f211025b0c1bc7a39a85bd690/xsdata-22.11.tar.gz
cd dist/working && tar -xzvf xsdata*
cp -r dist/working/xsdata-22.11/xsdata dist/blenderbim/libs/site/packages/
rm -rf dist/working
# Required by bcf # Required by bcf
mkdir dist/working mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/11/bc/5afb61dd5d863e5cf77cd952445c50c17e65953405986f19e97e4389692a/elementpath-3.0.2.tar.gz cd dist/working && wget https://files.pythonhosted.org/packages/11/bc/5afb61dd5d863e5cf77cd952445c50c17e65953405986f19e97e4389692a/elementpath-3.0.2.tar.gz
@@ -28,3 +28,7 @@ class BcfStore:
if not BcfStore.bcfxml: if not BcfStore.bcfxml:
BcfStore.bcfxml = bcf.v2.bcfxml.BcfXml() BcfStore.bcfxml = bcf.v2.bcfxml.BcfXml()
return BcfStore.bcfxml return BcfStore.bcfxml
@classmethod
def set(cls, bcfxml):
cls.bcfxml = bcfxml
@@ -20,7 +20,6 @@ import os
import bpy import bpy
import bcf import bcf
import bcf.bcfxml import bcf.bcfxml
import bcf.v2.data
import numpy as np import numpy as np
import ifcopenshell import ifcopenshell
import ifcopenshell.util.unit import ifcopenshell.util.unit
@@ -38,8 +37,8 @@ class NewBcfProject(bpy.types.Operator):
def execute(self, context): def execute(self, context):
context.scene.BCFProperties.is_loaded = False context.scene.BCFProperties.is_loaded = False
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcf.v2.bcfxml.BcfXml.create_new("New Project")
bcfxml.new_project() bcfstore.BcfStore.set(bcfxml)
bpy.ops.bim.load_bcf_project() bpy.ops.bim.load_bcf_project()
context.scene.BCFProperties.is_loaded = True context.scene.BCFProperties.is_loaded = True
return {"FINISHED"} return {"FINISHED"}
@@ -97,34 +96,34 @@ class LoadBcfTopic(bpy.types.Operator):
new = context.scene.BCFProperties.topics[self.topic_index] new = context.scene.BCFProperties.topics[self.topic_index]
data_map = { data_map = {
"name": topic.guid, "name": topic.guid,
"title": topic.title, "title": topic.topic.title,
"type": topic.topic_type, "type": topic.topic.topic_type,
"status": topic.topic_status, "status": topic.topic.topic_status,
"priority": topic.priority, "priority": topic.topic.priority,
"stage": topic.stage, "stage": topic.topic.stage,
"creation_date": topic.creation_date, "creation_date": topic.topic.creation_date,
"creation_author": topic.creation_author, "creation_author": topic.topic.creation_author,
"modified_date": topic.modified_date, "modified_date": topic.topic.modified_date,
"modified_author": topic.modified_author, "modified_author": topic.topic.modified_author,
"assigned_to": topic.assigned_to, "assigned_to": topic.topic.assigned_to,
"due_date": topic.due_date, "due_date": topic.topic.due_date,
"description": topic.description, "description": topic.topic.description,
} }
for key, value in data_map.items(): for key, value in data_map.items():
if value is not None: if value is not None:
setattr(new, key, str(value)) setattr(new, key, str(value))
new.reference_links.clear() new.reference_links.clear()
for reference_link in topic.reference_links: for reference_link in topic.topic.reference_link:
new_reference_link = new.reference_links.add() new_reference_link = new.reference_links.add()
new_reference_link.name = reference_link new_reference_link.name = reference_link
new.labels.clear() new.labels.clear()
for label in topic.labels: for label in topic.topic.labels:
new_label = new.labels.add() new_label = new.labels.add()
new_label.name = label new_label.name = label
if topic.bim_snippet: if topic.topic.bim_snippet:
data_map = { data_map = {
"type": topic.bim_snippet.snippet_type, "type": topic.bim_snippet.snippet_type,
"is_external": topic.bim_snippet.is_external, "is_external": topic.bim_snippet.is_external,
@@ -136,7 +135,7 @@ class LoadBcfTopic(bpy.types.Operator):
setattr(new.bim_snippet, key, value) setattr(new.bim_snippet, key, value)
new.document_references.clear() new.document_references.clear()
for doc in topic.document_references: for doc in topic.topic.document_reference:
new_document_references = new.document_references.add() new_document_references = new.document_references.add()
data_map = { data_map = {
"reference": doc.referenced_document, "reference": doc.referenced_document,
@@ -149,7 +148,7 @@ class LoadBcfTopic(bpy.types.Operator):
setattr(new_document_references, key, value) setattr(new_document_references, key, value)
new.related_topics.clear() new.related_topics.clear()
for related_topic in topic.related_topics: for related_topic in topic.topic.related_topic:
new_related_topic = new.related_topics.add() new_related_topic = new.related_topics.add()
new_related_topic.name = related_topic.guid new_related_topic.name = related_topic.guid
@@ -276,7 +275,7 @@ class AddBcfTopic(bpy.types.Operator):
def execute(self, context): def execute(self, context):
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
bcfxml.add_topic() bcfxml.add_topic("New Topic", "", context.scene.BCFProperties.author)
bpy.ops.bim.load_bcf_topics() bpy.ops.bim.load_bcf_topics()
return {"FINISHED"} return {"FINISHED"}