Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 7dd4014

Browse files
committed
Migrate from bcfplugin to new bcf library in the BlenderBIM Add-on
1 parent d08da0a commit 7dd4014

8 files changed

Lines changed: 292 additions & 506 deletions

File tree

src/bcf/bcf/bcfxml.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@ def __init__(self):
3030
self.logger = logging.getLogger("bcfxml")
3131
self.author = "john@doe.com"
3232
self.project = bcf.data.Project()
33+
self.version = "2.1"
3334
self.topics = {}
3435

36+
def new_project(self):
37+
self.project.project_id = str(uuid.uuid4())
38+
self.project.name = "New Project"
39+
self.topics = {}
40+
if self.filepath:
41+
self.close_project()
42+
self.filepath = tempfile.mkdtemp()
43+
self.edit_project()
44+
self.edit_version()
45+
3546
def get_project(self, filepath=None):
3647
if not filepath:
3748
return self.project
@@ -62,7 +73,15 @@ def save_project(self, filepath):
6273

6374
def get_version(self):
6475
data = self._read_xml("bcf.version", "version.xsd")
65-
return data["@VersionId"]
76+
self.version = data["@VersionId"]
77+
return self.version
78+
79+
def edit_version(self):
80+
self.document = minidom.Document()
81+
root = self._create_element(self.document, "Version", {"VersionId": self.version})
82+
version = self._create_element(root, "DetailedVersion", text=self.version)
83+
with open(os.path.join(self.filepath, "bcf.version"), "wb") as f:
84+
f.write(self.document.toprettyxml(encoding="utf-8"))
6685

6786
def get_topics(self):
6887
self.topics = {}
@@ -117,14 +136,15 @@ def get_topic(self, guid):
117136
"priority": "Priority",
118137
"index": "Index",
119138
"labels": "Labels",
139+
"reference_links": "ReferenceLink",
120140
"modified_date": "ModifiedDate",
121141
"modified_author": "ModifiedAuthor",
122142
"due_date": "DueDate",
123143
"assigned_to": "AssignedTo",
124144
"stage": "Stage",
125145
"description": "Description",
126-
"topic_status": "TopicStatus",
127-
"topic_type": "TopicType",
146+
"topic_status": "@TopicStatus",
147+
"topic_type": "@TopicType",
128148
}
129149
for key, value in optional_keys.items():
130150
if value in data["Topic"]:
@@ -173,6 +193,7 @@ def add_topic(self, topic=None):
173193
topic.title = "New Topic"
174194
os.mkdir(os.path.join(self.filepath, topic.guid))
175195
self.edit_topic(topic)
196+
return topic
176197

177198
def edit_topic(self, topic):
178199
if not topic.creation_date:

src/ifcblenderexport/Makefile

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -138,57 +138,22 @@ endif
138138
cp -r dist/working/pyparsing-2.4.5/pyparsing.py dist/blenderbim/libs/site/packages/
139139
rm -rf dist/working
140140

141-
# Required by bcfplugin
142-
mkdir dist/working
143-
cd dist/working && wget https://files.pythonhosted.org/packages/82/c3/534ddba230bd4fbbd3b7a3d35f3341d014cca213f369a9940925e7e5f691/pytz-2019.3.tar.gz
144-
cd dist/working && tar -xzvf pytz*
145-
cp -r dist/working/pytz-2019.3/pytz dist/blenderbim/libs/site/packages/
146-
rm -rf dist/working
147-
148-
# Required by bcfplugin
149-
mkdir dist/working
150-
cd dist/working && wget https://files.pythonhosted.org/packages/be/ed/5bbc91f03fa4c839c4c7360375da77f9659af5f7086b7a7bdda65771c8e0/python-dateutil-2.8.1.tar.gz
151-
cd dist/working && tar -xzvf python-dateutil*
152-
cp -r dist/working/python-dateutil-2.8.1/dateutil dist/blenderbim/libs/site/packages/
153-
rm -rf dist/working
154-
155-
# Required by bcfplugin
156-
mkdir dist/working
157-
cd dist/working && wget https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz
158-
cd dist/working && tar -xzvf six*
159-
cp -r dist/working/six-1.14.0/six.py dist/blenderbim/libs/site/packages/
160-
rm -rf dist/working
161-
162-
# Required by bcfplugin
141+
# Required by bcf
163142
mkdir dist/working
164143
cd dist/working && wget https://files.pythonhosted.org/packages/bb/41/ad9ce53bb978b68af8ae415293cafc89b165b8ad55a593725299dca76729/xmlschema-1.1.1.tar.gz
165144
cd dist/working && tar -xzvf xmlschema*
166145
cp -r dist/working/xmlschema-1.1.1/xmlschema dist/blenderbim/libs/site/packages/
167146
rm -rf dist/working
168147

169-
# Required by bcfplugin
170-
mkdir dist/working
171-
cd dist/working && wget https://files.pythonhosted.org/packages/12/f9/f9960222d5274944b01391749e55e4dcdf28d8f0c108b64ac931ceff6fdb/elementpath-1.4.3.tar.gz
172-
cd dist/working && tar -xzvf elementpath*
173-
cp -r dist/working/elementpath-1.4.3/elementpath dist/blenderbim/libs/site/packages/
174-
rm -rf dist/working
175-
176-
# Provides bcfplugin functionality
177-
mkdir dist/working
178-
cd dist/working && wget https://github.com/podestplatz/bcf/archive/master.zip
179-
cd dist/working && unzip master*
180-
cp -r dist/working/bcf-master/bcfplugin dist/blenderbim/libs/site/packages/
181-
rm -rf dist/working
182-
183-
# Required by bcfplugin
184-
mkdir dist/working
185-
cd dist/working && wget https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_2_1/Schemas/project.xsd
186-
cd dist/working && wget https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_2_1/Extension%20Schemas/extensions.xsd
187-
cd dist/working && wget https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_2_1/Schemas/markup.xsd
188-
cd dist/working && wget https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_2_1/Schemas/version.xsd
189-
cd dist/working && wget https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_2_1/Schemas/visinfo.xsd
190-
mkdir dist/blenderbim/libs/site/packages/bcfplugin/schemas/
191-
cp -r dist/working/*.xsd dist/blenderbim/libs/site/packages/bcfplugin/schemas/
148+
# Provides bcf functionality
149+
mkdir dist/blenderbim/libs/site/packages/bcf
150+
mkdir dist/blenderbim/libs/site/packages/bcf/xsd
151+
cd dist/blenderbim/libs/site/packages/bcf && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/bcfxml.py
152+
cd dist/blenderbim/libs/site/packages/bcf && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/data.py
153+
cd dist/blenderbim/libs/site/packages/bcf/xsd && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/xsd/markup.xsd
154+
cd dist/blenderbim/libs/site/packages/bcf/xsd && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/xsd/project.xsd
155+
cd dist/blenderbim/libs/site/packages/bcf/xsd && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/xsd/version.xsd
156+
cd dist/blenderbim/libs/site/packages/bcf/xsd && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/bcf/bcf/xsd/visinfo.xsd
192157
rm -rf dist/working
193158

194159
# Required by IFCCSV and ifcopenshell.util.selector

src/ifcblenderexport/blenderbim/bim/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
operator.SelectType,
2828
operator.NewBcfProject,
2929
operator.LoadBcfProject,
30+
operator.LoadBcfTopics,
3031
operator.SaveBcfProject,
3132
operator.AddBcfTopic,
3233
operator.ViewBcfTopic,
3334
operator.ActivateBcfViewpoint,
34-
operator.OpenBcfFileReference,
35+
operator.OpenUri,
3536
operator.OpenBcfReferenceLink,
36-
operator.OpenBcfBimSnippetSchema,
37-
operator.OpenBcfBimSnippetReference,
38-
operator.OpenBcfDocumentReference,
3937
operator.SelectFeaturesDir,
4038
operator.SelectDiffJsonFile,
4139
operator.SelectDiffNewFile,
@@ -260,12 +258,9 @@
260258
prop.Schedule,
261259
prop.DrawingStyle,
262260
prop.Sheet,
261+
prop.BcfBimSnippet,
262+
prop.BcfDocumentReference,
263263
prop.BcfTopic,
264-
prop.BcfTopicLabel,
265-
prop.BcfTopicFile,
266-
prop.BcfTopicLink,
267-
prop.BcfTopicDocumentReference,
268-
prop.BcfTopicRelatedTopic,
269264
prop.Subcontext,
270265
prop.PresentationLayer,
271266
prop.BIMProperties,

src/ifcblenderexport/blenderbim/bim/bcf.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import bcf
2+
import bcf.bcfxml
3+
4+
class BcfStore:
5+
bcfxml = None
6+
7+
@staticmethod
8+
def get_bcfxml():
9+
if not BcfStore.bcfxml:
10+
BcfStore.bcfxml = bcf.bcfxml.BcfXml()
11+
return BcfStore.bcfxml

0 commit comments

Comments
 (0)