mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Use module variables as dynamic enum containers
As explained in https://devtalk.blender.org/t/can-bpy-props-be-used-for-dynamic-lists/10130/11 Dynamic enums can crash Blender if container is not set using at least a module-level variable. Using global keyword is not mandatory but may help debugging
This commit is contained in:
@@ -14,27 +14,37 @@ from bpy.props import (
|
|||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_persons_enum = []
|
||||||
|
_organisations_enum = []
|
||||||
|
|
||||||
|
def purge():
|
||||||
|
global _persons_enum
|
||||||
|
global _organisations_enum
|
||||||
|
_persons_enum.clear()
|
||||||
|
_organisations_enum.clear()
|
||||||
|
|
||||||
def getPersons(self, context):
|
def getPersons(self, context):
|
||||||
|
global _persons_enum
|
||||||
if not Data.is_loaded:
|
if not Data.is_loaded:
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
results = []
|
_persons_enum.clear()
|
||||||
for ifc_id, person in Data.people.items():
|
for ifc_id, person in Data.people.items():
|
||||||
if "Id" in person:
|
if "Id" in person:
|
||||||
identifier = person["Id"] or ""
|
identifier = person["Id"] or ""
|
||||||
else:
|
else:
|
||||||
identifier = person["Identification"] or ""
|
identifier = person["Identification"] or ""
|
||||||
results.append((str(ifc_id), identifier, ""))
|
_persons_enum.append((str(ifc_id), identifier, ""))
|
||||||
return results
|
return _persons_enum
|
||||||
|
|
||||||
|
|
||||||
def getOrganisations(self, context):
|
def getOrganisations(self, context):
|
||||||
|
global _organisations_enum
|
||||||
if not Data.is_loaded:
|
if not Data.is_loaded:
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
results = []
|
_organisations_enum.clear()
|
||||||
for ifc_id, organisation in Data.organisations.items():
|
for ifc_id, organisation in Data.organisations.items():
|
||||||
results.append((str(ifc_id), organisation["Name"], ""))
|
_organisations_enum.append((str(ifc_id), organisation["Name"], ""))
|
||||||
return results
|
return _organisations_enum
|
||||||
|
|
||||||
|
|
||||||
class Address(PropertyGroup):
|
class Address(PropertyGroup):
|
||||||
|
|||||||
Reference in New Issue
Block a user