Implement delete BCF viewpoint

This commit is contained in:
Dion Moult
2020-12-22 16:22:29 +11:00
parent 2226d5a565
commit ee42703f9f
4 changed files with 44 additions and 13 deletions
+16 -7
View File
@@ -206,6 +206,8 @@ class BcfXml:
self.document = minidom.Document()
root = self._create_element(self.document, "Markup")
self.write_header(topic.header, root)
topic_el = self._create_element(
root,
"Topic",
@@ -216,10 +218,22 @@ class BcfXml:
},
)
for reference_link in topic.reference_links:
self._create_element(topic_el, "ReferenceLink", text=reference_link)
text_map = {
"Title": topic.title,
"Priority": topic.priority,
"Index": topic.index,
}
for key, value in text_map.items():
if value:
self._create_element(topic_el, key, text=value)
for label in topic.labels:
self._create_element(topic_el, "Labels", text=label)
text_map = {
"CreationDate": topic.creation_date,
"CreationAuthor": topic.creation_author,
"ModifiedDate": topic.modified_date,
@@ -233,10 +247,6 @@ class BcfXml:
if value:
self._create_element(topic_el, key, text=value)
for reference_link in topic.reference_links:
self._create_element(topic_el, "ReferenceLink", text=reference_link)
for label in topic.labels:
self._create_element(topic_el, "Labels", text=label)
if topic.bim_snippet:
bim_snippet = self._create_element(
topic_el,
@@ -254,7 +264,6 @@ class BcfXml:
for related_topic in topic.related_topics:
self._create_element(topic_el, "RelatedTopic", {"Guid": related_topic.guid})
self.write_header(topic.header, root)
self.write_comments(topic.comments, root)
self.write_viewpoints(topic.viewpoints, root, topic)
@@ -334,7 +343,7 @@ class BcfXml:
def write_viewpoint(self, viewpoint, topic):
document = minidom.Document()
root = self._create_element(document, "VisualizationInfo")
root = self._create_element(document, "VisualizationInfo", { "Guid": viewpoint.guid })
self.write_viewpoint_components(viewpoint, root)
self.write_viewpoint_orthogonal_camera(viewpoint, root)
self.write_viewpoint_perspective_camera(viewpoint, root)
@@ -354,7 +363,7 @@ class BcfXml:
"ViewSetupHints",
{
"SpacesVisible": viewpoint.components.view_setup_hints.spaces_visible,
"SpaceBoundiresVisible": viewpoint.components.view_setup_hints.space_boundaries_visible,
"SpaceBoundariesVisible": viewpoint.components.view_setup_hints.space_boundaries_visible,
"OpeningsVisible": viewpoint.components.view_setup_hints.openings_visible,
},
)
@@ -36,6 +36,7 @@ if bpy is not None:
operator.SaveBcfProject,
operator.AddBcfTopic,
operator.ViewBcfTopic,
operator.RemoveBcfViewpoint,
operator.ActivateBcfViewpoint,
operator.OpenUri,
operator.OpenBcfReferenceLink,
@@ -737,6 +737,22 @@ class ViewBcfTopic(bpy.types.Operator):
return {"FINISHED"}
class RemoveBcfViewpoint(bpy.types.Operator):
bl_idname = "bim.remove_bcf_viewpoint"
bl_label = "Remove BCF Viewpoint"
def execute(self, context):
bcfxml = bcfstore.BcfStore.get_bcfxml()
props = bpy.context.scene.BCFProperties
blender_topic = props.topics[props.active_topic_index]
viewpoint_guid = blender_topic.viewpoints
topic = bcfxml.topics[blender_topic.name]
bcfxml.delete_viewpoint(viewpoint_guid, topic)
props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic
print(bcfxml.filepath)
return {"FINISHED"}
class ActivateBcfViewpoint(bpy.types.Operator):
bl_idname = "bim.activate_bcf_viewpoint"
bl_label = "Activate BCF Viewpoint"
@@ -745,7 +761,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
bcfxml = bcfstore.BcfStore.get_bcfxml()
props = bpy.context.scene.BCFProperties
blender_topic = props.topics[props.active_topic_index]
topic = bcfxml.topics[blender_topic.guid]
topic = bcfxml.topics[blender_topic.name]
if not topic.viewpoints:
return {"FINISHED"}
+10 -5
View File
@@ -1696,6 +1696,7 @@ class BIM_PT_bcf(Panel):
row = layout.row()
row.prop(topic, "viewpoints")
row.operator("bim.activate_bcf_viewpoint", icon="SCENE", text="")
row.operator("bim.remove_bcf_viewpoint", icon="X", text="")
col = layout.column(align=True)
if topic.type:
@@ -1757,8 +1758,8 @@ class BIM_PT_bcf_metadata(Panel):
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
box.label(text=f.date)
#box.label(text=f.ifc_project)
#box.label(text=f.ifc_spatial_structure_element)
# box.label(text=f.ifc_project)
# box.label(text=f.ifc_spatial_structure_element)
if topic.reference_links:
layout.label(text="Reference Links:")
@@ -1850,7 +1851,7 @@ class BIM_PT_bcf_comments(Panel):
while words and total_line_chars < props.comment_text_width:
word = words.pop(0)
line_words.append(word)
total_line_chars += len(word) + 1 # 1 is for the space
total_line_chars += len(word) + 1 # 1 is for the space
box.label(text=" ".join(line_words))
box.separator()
@@ -2199,14 +2200,16 @@ class BIM_UL_clash_sets(bpy.types.UIList):
else:
layout.label(text="", translate=False)
class BIM_UL_smart_groups(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
ob = data
if item:
layout.label(text=str(item.number), translate=False, icon='NONE', icon_value=0)
layout.label(text=str(item.number), translate=False, icon="NONE", icon_value=0)
else:
layout.label(text="", translate=False)
class BIM_UL_constraints(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
ob = data
@@ -2469,6 +2472,7 @@ class BIM_PT_qto_utilities(Panel):
row = layout.row(align=True)
row.operator("bim.calculate_object_volumes")
class BIM_PT_clash_manager(Panel):
bl_idname = "BIM_PT_clash_manager"
bl_label = "Clash Manager"
@@ -2503,11 +2507,12 @@ class BIM_PT_clash_manager(Panel):
row = layout.row(align=True)
row.operator("bim.load_smart_groups_for_active_clash_set")
layout.template_list('BIM_UL_smart_groups', '', props, 'smart_clash_groups', props, 'active_smart_group_index')
layout.template_list("BIM_UL_smart_groups", "", props, "smart_clash_groups", props, "active_smart_group_index")
row = layout.row(align=True)
row.operator("bim.select_smart_group")
class BIM_PT_misc_utilities(Panel):
bl_idname = "BIM_PT_misc_utilities"
bl_label = "Miscellaneous"