mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
You can now add new BCF topics to a BCF project
This commit is contained in:
@@ -27,6 +27,7 @@ if bpy is not None:
|
|||||||
operator.SelectType,
|
operator.SelectType,
|
||||||
operator.LoadBcfProject,
|
operator.LoadBcfProject,
|
||||||
operator.SaveBcfProject,
|
operator.SaveBcfProject,
|
||||||
|
operator.AddBcfTopic,
|
||||||
operator.ViewBcfTopic,
|
operator.ViewBcfTopic,
|
||||||
operator.ActivateBcfViewpoint,
|
operator.ActivateBcfViewpoint,
|
||||||
operator.OpenBcfFileReference,
|
operator.OpenBcfFileReference,
|
||||||
|
|||||||
@@ -517,13 +517,14 @@ class LoadBcfProject(bpy.types.Operator):
|
|||||||
|
|
||||||
bcfplugin.openProject(self.filepath)
|
bcfplugin.openProject(self.filepath)
|
||||||
bcf.BcfStore.topics = bcfplugin.getTopics()
|
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:
|
while len(bpy.context.scene.BCFProperties.topics) > 0:
|
||||||
bpy.context.scene.BCFProperties.topics.remove(0)
|
bpy.context.scene.BCFProperties.topics.remove(0)
|
||||||
for topic in bcf.BcfStore.topics:
|
for topic in bcf.BcfStore.topics:
|
||||||
new = bpy.context.scene.BCFProperties.topics.add()
|
new = bpy.context.scene.BCFProperties.topics.add()
|
||||||
new.name = topic[0]
|
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.is_editable = True
|
||||||
bpy.context.scene.BCFProperties.name = bcfplugin.getProjectName()
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
@@ -546,6 +547,21 @@ class SaveBcfProject(bpy.types.Operator):
|
|||||||
return {"RUNNING_MODAL"}
|
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):
|
class ViewBcfTopic(bpy.types.Operator):
|
||||||
bl_idname = "bim.view_bcf_topic"
|
bl_idname = "bim.view_bcf_topic"
|
||||||
bl_label = "Get BCF Topic"
|
bl_label = "Get BCF Topic"
|
||||||
|
|||||||
@@ -916,6 +916,8 @@ def updateBcfProjectName(self, context):
|
|||||||
|
|
||||||
|
|
||||||
def updateBcfTopicAttribute(context, name, value):
|
def updateBcfTopicAttribute(context, name, value):
|
||||||
|
if not bpy.context.scene.BCFProperties.is_editable:
|
||||||
|
return
|
||||||
import bcfplugin
|
import bcfplugin
|
||||||
props = bpy.context.scene.BCFProperties
|
props = bpy.context.scene.BCFProperties
|
||||||
topic = bcf.BcfStore.topics[props.active_topic_index][1]
|
topic = bcf.BcfStore.topics[props.active_topic_index][1]
|
||||||
@@ -925,8 +927,7 @@ def updateBcfTopicAttribute(context, name, value):
|
|||||||
|
|
||||||
|
|
||||||
def updateBcfTopicName(self, context):
|
def updateBcfTopicName(self, context):
|
||||||
if bpy.context.scene.BCFProperties.name:
|
updateBcfTopicAttribute(context, "title", self.name)
|
||||||
updateBcfTopicAttribute(context, "title", self.name)
|
|
||||||
|
|
||||||
|
|
||||||
def updateBcfTopicType(self, context):
|
def updateBcfTopicType(self, context):
|
||||||
@@ -945,6 +946,10 @@ def updateBcfTopicStage(self, context):
|
|||||||
updateBcfTopicAttribute(context, "stage", self.topic_stage)
|
updateBcfTopicAttribute(context, "stage", self.topic_stage)
|
||||||
|
|
||||||
|
|
||||||
|
def updateBcfTopicDescription(self, context):
|
||||||
|
updateBcfTopicAttribute(context, "description", self.topic_description)
|
||||||
|
|
||||||
|
|
||||||
class BcfTopic(PropertyGroup):
|
class BcfTopic(PropertyGroup):
|
||||||
name: StringProperty(name="Name", update=updateBcfTopicName)
|
name: StringProperty(name="Name", update=updateBcfTopicName)
|
||||||
|
|
||||||
@@ -1634,6 +1639,7 @@ class BIMProperties(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class BCFProperties(PropertyGroup):
|
class BCFProperties(PropertyGroup):
|
||||||
|
is_editable: BoolProperty(name="Is Editable", default=False)
|
||||||
name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
|
name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
|
||||||
author: StringProperty(default="john@doe.com", name="Author Email")
|
author: StringProperty(default="john@doe.com", name="Author Email")
|
||||||
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
|
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
|
||||||
@@ -1650,7 +1656,7 @@ class BCFProperties(PropertyGroup):
|
|||||||
topic_modified_author: StringProperty(default="", name="Topic Modified By")
|
topic_modified_author: StringProperty(default="", name="Topic Modified By")
|
||||||
topic_assigned_to: StringProperty(default="", name="Topic Assigned To")
|
topic_assigned_to: StringProperty(default="", name="Topic Assigned To")
|
||||||
topic_due_date: StringProperty(default="", name="Topic Due Date")
|
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_labels: CollectionProperty(name="BCF Topic Labels", type=BcfTopicLabel)
|
||||||
topic_files: CollectionProperty(name="BCF Topic Files", type=BcfTopicFile)
|
topic_files: CollectionProperty(name="BCF Topic Files", type=BcfTopicFile)
|
||||||
topic_links: CollectionProperty(name="BCF Topic Links", type=BcfTopicLink)
|
topic_links: CollectionProperty(name="BCF Topic Links", type=BcfTopicLink)
|
||||||
|
|||||||
@@ -1678,7 +1678,10 @@ class BIM_PT_bcf(Panel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
props = bpy.context.scene.BCFProperties
|
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 = layout.row()
|
||||||
row.prop(props, "topic_description", text="")
|
row.prop(props, "topic_description", text="")
|
||||||
|
|||||||
Reference in New Issue
Block a user