You can now add new BCF topics to a BCF project

This commit is contained in:
Dion Moult
2020-12-14 13:29:52 +11:00
parent e208dd0381
commit 4f2bf3a36f
4 changed files with 32 additions and 6 deletions
@@ -27,6 +27,7 @@ if bpy is not None:
operator.SelectType,
operator.LoadBcfProject,
operator.SaveBcfProject,
operator.AddBcfTopic,
operator.ViewBcfTopic,
operator.ActivateBcfViewpoint,
operator.OpenBcfFileReference,
@@ -517,13 +517,14 @@ class LoadBcfProject(bpy.types.Operator):
bcfplugin.openProject(self.filepath)
bcf.BcfStore.topics = bcfplugin.getTopics()
bpy.context.scene.BCFProperties.is_editable = False
bpy.context.scene.BCFProperties.name = bcfplugin.getProjectName()
while len(bpy.context.scene.BCFProperties.topics) > 0:
bpy.context.scene.BCFProperties.topics.remove(0)
for topic in bcf.BcfStore.topics:
new = bpy.context.scene.BCFProperties.topics.add()
new.name = topic[0]
# Note: set this last, as we use it to check whether or not the project has been loaded
bpy.context.scene.BCFProperties.name = bcfplugin.getProjectName()
bpy.context.scene.BCFProperties.is_editable = True
return {"FINISHED"}
def invoke(self, context, event):
@@ -546,6 +547,21 @@ class SaveBcfProject(bpy.types.Operator):
return {"RUNNING_MODAL"}
class AddBcfTopic(bpy.types.Operator):
bl_idname = "bim.add_bcf_topic"
bl_label = "Add BCF Topic"
def execute(self, context):
import bcfplugin
bcfplugin.addTopic("New Topic", bpy.context.scene.BCFProperties.author)
bpy.context.scene.BCFProperties.is_editable = False
new = bpy.context.scene.BCFProperties.topics.add()
new.name = "New Topic"
bcf.BcfStore.topics = bcfplugin.getTopics()
bpy.context.scene.BCFProperties.is_editable = True
return {"FINISHED"}
class ViewBcfTopic(bpy.types.Operator):
bl_idname = "bim.view_bcf_topic"
bl_label = "Get BCF Topic"
+9 -3
View File
@@ -916,6 +916,8 @@ def updateBcfProjectName(self, context):
def updateBcfTopicAttribute(context, name, value):
if not bpy.context.scene.BCFProperties.is_editable:
return
import bcfplugin
props = bpy.context.scene.BCFProperties
topic = bcf.BcfStore.topics[props.active_topic_index][1]
@@ -925,8 +927,7 @@ def updateBcfTopicAttribute(context, name, value):
def updateBcfTopicName(self, context):
if bpy.context.scene.BCFProperties.name:
updateBcfTopicAttribute(context, "title", self.name)
updateBcfTopicAttribute(context, "title", self.name)
def updateBcfTopicType(self, context):
@@ -945,6 +946,10 @@ def updateBcfTopicStage(self, context):
updateBcfTopicAttribute(context, "stage", self.topic_stage)
def updateBcfTopicDescription(self, context):
updateBcfTopicAttribute(context, "description", self.topic_description)
class BcfTopic(PropertyGroup):
name: StringProperty(name="Name", update=updateBcfTopicName)
@@ -1634,6 +1639,7 @@ class BIMProperties(PropertyGroup):
class BCFProperties(PropertyGroup):
is_editable: BoolProperty(name="Is Editable", default=False)
name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
author: StringProperty(default="john@doe.com", name="Author Email")
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
@@ -1650,7 +1656,7 @@ class BCFProperties(PropertyGroup):
topic_modified_author: StringProperty(default="", name="Topic Modified By")
topic_assigned_to: StringProperty(default="", name="Topic Assigned To")
topic_due_date: StringProperty(default="", name="Topic Due Date")
topic_description: StringProperty(default="", name="Topic Description")
topic_description: StringProperty(default="", name="Topic Description", update=updateBcfTopicDescription)
topic_labels: CollectionProperty(name="BCF Topic Labels", type=BcfTopicLabel)
topic_files: CollectionProperty(name="BCF Topic Files", type=BcfTopicFile)
topic_links: CollectionProperty(name="BCF Topic Links", type=BcfTopicLink)
+4 -1
View File
@@ -1678,7 +1678,10 @@ class BIM_PT_bcf(Panel):
return
props = bpy.context.scene.BCFProperties
layout.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
row = layout.row()
row.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
col = row.column(align=True)
col.operator("bim.add_bcf_topic", icon="ADD", text="")
row = layout.row()
row.prop(props, "topic_description", text="")