Add support for BCF topic BIM snippets

This commit is contained in:
Dion Moult
2020-03-25 16:20:24 +11:00
parent f2e203d699
commit 2678dc3a09
4 changed files with 65 additions and 2 deletions
@@ -37,6 +37,8 @@ if bpy is not None:
operator.GetBcfTopics,
operator.ActivateBcfViewpoint,
operator.OpenBcfReferenceLink,
operator.OpenBcfBimSnippetSchema,
operator.OpenBcfBimSnippetReference,
operator.SelectFeaturesDir,
operator.SelectDiffJsonFile,
operator.SelectDiffNewFile,
@@ -457,6 +457,33 @@ class OpenBcfReferenceLink(bpy.types.Operator):
return {'FINISHED'}
class OpenBcfBimSnippetSchema(bpy.types.Operator):
bl_idname = 'bim.open_bcf_bim_snippet_schema'
bl_label = 'Open BCF BIM Snippet Schema'
def execute(self, context):
webbrowser.open(bpy.context.scene.BCFProperties.topic_snippet_schema)
return {'FINISHED'}
class OpenBcfBimSnippetReference(bpy.types.Operator):
bl_idname = 'bim.open_bcf_bim_snippet_reference'
bl_label = 'Open BCF BIM Snippet Reference'
topic_guid: bpy.props.StringProperty()
def execute(self, context):
import bcfplugin
if bpy.context.scene.BCFProperties.topic_snippet_is_external:
webbrowser.open(bpy.context.scene.BCFProperties.topic_snippet_reference)
return {'FINISHED'}
webbrowser.open('file:///' + os.path.join(
bcfplugin.util.getBcfDir(),
self.topic_guid,
bpy.context.scene.BCFProperties.topic_snippet_reference
))
return {'FINISHED'}
class SelectAudited(bpy.types.Operator):
bl_idname = 'bim.select_audited'
bl_label = 'Select Audited'
+20
View File
@@ -379,6 +379,8 @@ def refreshBcfTopic(self, context):
props = bpy.context.scene.BCFProperties
topic = bcf.BcfStore.topics[props.active_topic_index][1]
props.topic_guid = str(topic.xmlId)
# Load metadata
props.topic_type = topic.type
props.topic_status = topic.status
@@ -413,6 +415,18 @@ def refreshBcfTopic(self, context):
new = props.topic_links.add()
new.name = link.value
# Load snippet
props.topic_has_snippet = bool(topic.bimSnippet)
if topic.bimSnippet:
props.topic_snippet_reference = topic.bimSnippet.reference.uri
if topic.bimSnippet.schema.uri:
props.topic_snippet_schema = topic.bimSnippet.schema.uri
props.topic_snippet_type = topic.bimSnippet.type
if topic.bimSnippet.external:
props.topic_snippet_is_external = topic.bimSnippet.external
else:
props.topic_snippet_is_external = False
# Load viewpoints
bcfviewpoints_enum.clear()
viewpoints = bcfplugin.getViewpoints(topic)
@@ -507,6 +521,7 @@ class BCFProperties(PropertyGroup):
topics: CollectionProperty(name='BCF Topics', type=BcfTopic)
active_topic_index: IntProperty(name='Active BCF Topic Index', update=refreshBcfTopic)
viewpoints: EnumProperty(items=getBcfViewpoints, name='BCF Viewpoints')
topic_guid: StringProperty(default='', name='Topic GUID')
topic_type: StringProperty(default='', name='Topic Type')
topic_status: StringProperty(default='', name='Topic Status')
topic_priority: StringProperty(default='', name='Topic Priority')
@@ -520,6 +535,11 @@ class BCFProperties(PropertyGroup):
topic_description: StringProperty(default='', name='Topic Description')
topic_labels: CollectionProperty(name='BCF Topic Labels', type=BcfTopicLabel)
topic_links: CollectionProperty(name='BCF Topic Links', type=BcfTopicLink)
topic_has_snippet: BoolProperty(name='BCF Topic Has Snippet', default=False)
topic_snippet_reference: StringProperty(name='BIM Snippet Reference')
topic_snippet_schema: StringProperty(name='BIM Snippet Schema')
topic_snippet_type: StringProperty(name='BIM Snippet Type')
topic_snippet_is_external: BoolProperty(name='Is BIM Snippet External')
class MapConversion(PropertyGroup):
+16 -2
View File
@@ -577,8 +577,8 @@ class BIM_PT_bcf(Panel):
layout.label(text="Reference Links:")
for index, label in enumerate(props.topic_links):
row = layout.row(align=True)
row.prop(label, 'name', text='')
row = layout.row()
row.prop(label, 'name', text='Link {}'.format(index + 1))
row.operator('bim.open_bcf_reference_link', icon='URL', text='').index = index
layout.label(text="Labels:")
@@ -586,6 +586,20 @@ class BIM_PT_bcf(Panel):
row = layout.row(align=True)
row.prop(label, 'name', text='')
layout.label(text="BIM Snippet:")
if props.topic_has_snippet:
row = layout.row(align=True)
row.prop(props, 'topic_snippet_type')
if props.topic_snippet_schema:
row.operator('bim.open_bcf_bim_snippet_schema', icon='URL', text='')
row = layout.row(align=True)
row.prop(props, 'topic_snippet_reference')
if props.topic_snippet_is_external:
row.operator('bim.open_bcf_bim_snippet_reference', icon='URL', text='')
else:
row.operator('bim.open_bcf_bim_snippet_reference', icon='FILE_FOLDER', text='').topic_guid = props.topic_guid
class BIM_PT_qa(Panel):
bl_label = "BIMTester Quality Auditing"