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

Commit 4f2bf3a

Browse files
committed
You can now add new BCF topics to a BCF project
1 parent e208dd0 commit 4f2bf3a

4 files changed

Lines changed: 32 additions & 6 deletions

File tree

src/ifcblenderexport/blenderbim/bim/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
operator.SelectType,
2828
operator.LoadBcfProject,
2929
operator.SaveBcfProject,
30+
operator.AddBcfTopic,
3031
operator.ViewBcfTopic,
3132
operator.ActivateBcfViewpoint,
3233
operator.OpenBcfFileReference,

src/ifcblenderexport/blenderbim/bim/operator.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,14 @@ def execute(self, context):
517517

518518
bcfplugin.openProject(self.filepath)
519519
bcf.BcfStore.topics = bcfplugin.getTopics()
520+
bpy.context.scene.BCFProperties.is_editable = False
521+
bpy.context.scene.BCFProperties.name = bcfplugin.getProjectName()
520522
while len(bpy.context.scene.BCFProperties.topics) > 0:
521523
bpy.context.scene.BCFProperties.topics.remove(0)
522524
for topic in bcf.BcfStore.topics:
523525
new = bpy.context.scene.BCFProperties.topics.add()
524526
new.name = topic[0]
525-
# Note: set this last, as we use it to check whether or not the project has been loaded
526-
bpy.context.scene.BCFProperties.name = bcfplugin.getProjectName()
527+
bpy.context.scene.BCFProperties.is_editable = True
527528
return {"FINISHED"}
528529

529530
def invoke(self, context, event):
@@ -546,6 +547,21 @@ def invoke(self, context, event):
546547
return {"RUNNING_MODAL"}
547548

548549

550+
class AddBcfTopic(bpy.types.Operator):
551+
bl_idname = "bim.add_bcf_topic"
552+
bl_label = "Add BCF Topic"
553+
554+
def execute(self, context):
555+
import bcfplugin
556+
bcfplugin.addTopic("New Topic", bpy.context.scene.BCFProperties.author)
557+
bpy.context.scene.BCFProperties.is_editable = False
558+
new = bpy.context.scene.BCFProperties.topics.add()
559+
new.name = "New Topic"
560+
bcf.BcfStore.topics = bcfplugin.getTopics()
561+
bpy.context.scene.BCFProperties.is_editable = True
562+
return {"FINISHED"}
563+
564+
549565
class ViewBcfTopic(bpy.types.Operator):
550566
bl_idname = "bim.view_bcf_topic"
551567
bl_label = "Get BCF Topic"

src/ifcblenderexport/blenderbim/bim/prop.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,8 @@ def updateBcfProjectName(self, context):
916916

917917

918918
def updateBcfTopicAttribute(context, name, value):
919+
if not bpy.context.scene.BCFProperties.is_editable:
920+
return
919921
import bcfplugin
920922
props = bpy.context.scene.BCFProperties
921923
topic = bcf.BcfStore.topics[props.active_topic_index][1]
@@ -925,8 +927,7 @@ def updateBcfTopicAttribute(context, name, value):
925927

926928

927929
def updateBcfTopicName(self, context):
928-
if bpy.context.scene.BCFProperties.name:
929-
updateBcfTopicAttribute(context, "title", self.name)
930+
updateBcfTopicAttribute(context, "title", self.name)
930931

931932

932933
def updateBcfTopicType(self, context):
@@ -945,6 +946,10 @@ def updateBcfTopicStage(self, context):
945946
updateBcfTopicAttribute(context, "stage", self.topic_stage)
946947

947948

949+
def updateBcfTopicDescription(self, context):
950+
updateBcfTopicAttribute(context, "description", self.topic_description)
951+
952+
948953
class BcfTopic(PropertyGroup):
949954
name: StringProperty(name="Name", update=updateBcfTopicName)
950955

@@ -1634,6 +1639,7 @@ class BIMProperties(PropertyGroup):
16341639

16351640

16361641
class BCFProperties(PropertyGroup):
1642+
is_editable: BoolProperty(name="Is Editable", default=False)
16371643
name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
16381644
author: StringProperty(default="john@doe.com", name="Author Email")
16391645
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
@@ -1650,7 +1656,7 @@ class BCFProperties(PropertyGroup):
16501656
topic_modified_author: StringProperty(default="", name="Topic Modified By")
16511657
topic_assigned_to: StringProperty(default="", name="Topic Assigned To")
16521658
topic_due_date: StringProperty(default="", name="Topic Due Date")
1653-
topic_description: StringProperty(default="", name="Topic Description")
1659+
topic_description: StringProperty(default="", name="Topic Description", update=updateBcfTopicDescription)
16541660
topic_labels: CollectionProperty(name="BCF Topic Labels", type=BcfTopicLabel)
16551661
topic_files: CollectionProperty(name="BCF Topic Files", type=BcfTopicFile)
16561662
topic_links: CollectionProperty(name="BCF Topic Links", type=BcfTopicLink)

src/ifcblenderexport/blenderbim/bim/ui.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,10 @@ def draw(self, context):
16781678
return
16791679

16801680
props = bpy.context.scene.BCFProperties
1681-
layout.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
1681+
row = layout.row()
1682+
row.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
1683+
col = row.column(align=True)
1684+
col.operator("bim.add_bcf_topic", icon="ADD", text="")
16821685

16831686
row = layout.row()
16841687
row.prop(props, "topic_description", text="")

0 commit comments

Comments
 (0)