You can new create new BCF projects from scratch

This commit is contained in:
Dion Moult
2020-12-14 13:51:01 +11:00
parent 4f2bf3a36f
commit 17a8b33387
4 changed files with 28 additions and 6 deletions
@@ -25,6 +25,7 @@ if bpy is not None:
operator.UnassignClass,
operator.SelectClass,
operator.SelectType,
operator.NewBcfProject,
operator.LoadBcfProject,
operator.SaveBcfProject,
operator.AddBcfTopic,
@@ -507,6 +507,24 @@ class RejectElement(bpy.types.Operator):
return {"FINISHED"}
class NewBcfProject(bpy.types.Operator):
bl_idname = "bim.new_bcf_project"
bl_label = "New BCF Project"
def execute(self, context):
import bcfplugin
bcfplugin.newProject("New BCF Project")
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)
bpy.context.scene.BCFProperties.is_editable = True
bpy.context.scene.BCFProperties.directory = bcfplugin.util.getBcfDir()
bpy.context.scene.BCFProperties.is_loaded = True
return {"FINISHED"}
class LoadBcfProject(bpy.types.Operator):
bl_idname = "bim.load_bcf_project"
bl_label = "Load BCF Project"
@@ -525,6 +543,7 @@ class LoadBcfProject(bpy.types.Operator):
new = bpy.context.scene.BCFProperties.topics.add()
new.name = topic[0]
bpy.context.scene.BCFProperties.is_editable = True
bpy.context.scene.BCFProperties.is_loaded = True
return {"FINISHED"}
def invoke(self, context, event):
@@ -1640,6 +1640,7 @@ class BIMProperties(PropertyGroup):
class BCFProperties(PropertyGroup):
is_editable: BoolProperty(name="Is Editable", default=False)
is_loaded: BoolProperty(name="Is Loaded", 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)
+7 -6
View File
@@ -1661,12 +1661,13 @@ class BIM_PT_bcf(Panel):
props = bpy.context.scene.BCFProperties
row = layout.row(align=True)
row.operator("bim.load_bcf_project")
row.operator("bim.new_bcf_project", text="New Project")
row.operator("bim.load_bcf_project", text="Load Project")
if not props.topics:
if not props.is_loaded:
return
row.operator("bim.save_bcf_project")
row.operator("bim.save_bcf_project", text="Save Project")
row = layout.row()
row.prop(props, "name")
@@ -1674,15 +1675,15 @@ class BIM_PT_bcf(Panel):
row = layout.row()
row.prop(props, "author")
if not props.topics:
return
props = bpy.context.scene.BCFProperties
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="")
if not props.topics:
return
row = layout.row()
row.prop(props, "topic_description", text="")