mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Profiles UI - update displayed psets when user is changing active profile
previously it would get stuck until some other operator would refresh ui
This commit is contained in:
@@ -290,9 +290,18 @@ class ProfilePsetsData(Data):
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
pprops = bpy.context.scene.BIMProfileProperties
|
||||
ifc_definition_id = pprops.profiles[pprops.active_profile_index].ifc_definition_id
|
||||
cls.data = {"psets": cls.psetqtos(tool.Ifc.get().by_id(ifc_definition_id), psets_only=True)}
|
||||
active_profile = tool.Profile.get_active_profile_ui()
|
||||
if active_profile:
|
||||
ifc_definition_id = active_profile.ifc_definition_id
|
||||
psets_data = cls.psetqtos(tool.Ifc.get().by_id(ifc_definition_id), psets_only=True)
|
||||
else:
|
||||
ifc_definition_id = 0
|
||||
psets_data = []
|
||||
|
||||
cls.data = {
|
||||
"ifc_definition_id": ifc_definition_id,
|
||||
"psets": psets_data,
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
|
||||
|
||||
@@ -664,7 +664,15 @@ class BIM_PT_profile_psets(Panel):
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
if not ProfilePsetsData.is_loaded:
|
||||
active_profile = tool.Profile.get_active_profile_ui()
|
||||
|
||||
if not active_profile:
|
||||
return
|
||||
|
||||
if (
|
||||
not ProfilePsetsData.is_loaded
|
||||
or active_profile.ifc_definition_id != ProfilePsetsData.data["ifc_definition_id"]
|
||||
):
|
||||
ProfilePsetsData.load()
|
||||
|
||||
props = context.scene.ProfilePsetProperties
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.profile
|
||||
import ifcopenshell.geom
|
||||
@@ -104,3 +105,10 @@ class Profile(bonsai.core.tool.Profile):
|
||||
# In UI unnamed profiles are not available, so we don't handle them.
|
||||
new_profile.ProfileName = profile.ProfileName + "_copy"
|
||||
return new_profile
|
||||
|
||||
@classmethod
|
||||
def get_active_profile_ui(cls) -> Union[bpy.types.PropertyGroup, None]:
|
||||
props = bpy.context.scene.BIMProfileProperties
|
||||
index = props.active_profile_index
|
||||
if len(props.profiles) > index >= 0:
|
||||
return props.profiles[index]
|
||||
|
||||
Reference in New Issue
Block a user