Fix error messages when using the search operator on blank file (F3)

This commit is contained in:
Gorgious
2022-07-23 15:03:26 +02:00
parent 40d5a94e2d
commit 733e80737a
3 changed files with 5 additions and 3 deletions
@@ -768,6 +768,8 @@ class ActivateBcfViewpoint(bpy.types.Operator):
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
props = context.scene.BCFProperties props = context.scene.BCFProperties
blender_topic = props.active_topic blender_topic = props.active_topic
if blender_topic is None:
return False
topic = bcfxml.topics[blender_topic.name] topic = bcfxml.topics[blender_topic.name]
return topic.viewpoints return topic.viewpoints
@@ -95,7 +95,7 @@ def getBcfViewpoints(self, context, force_update=False):
props = context.scene.BCFProperties props = context.scene.BCFProperties
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = props.active_topic topic = props.active_topic
viewpoints = bcfxml.get_viewpoints(topic.name) viewpoints = bcfxml.get_viewpoints(topic.name) if topic else {}
bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())]) bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())])
return bcfviewpoints_enum return bcfviewpoints_enum
@@ -132,7 +132,7 @@ class UpdateRepresentation(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object.mode == "OBJECT" return context.active_object and context.active_object.mode == "OBJECT"
def execute(self, context): def execute(self, context):
return IfcStore.execute_ifc_operator(self, context) return IfcStore.execute_ifc_operator(self, context)
@@ -240,7 +240,7 @@ class UpdateParametricRepresentation(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object.mode == "OBJECT" return context.active_object and context.active_object.mode == "OBJECT"
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()