mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
ifcopenshell.settings.unpack_non_aggregate_inverses
This commit is contained in:
@@ -29,6 +29,7 @@ import operator
|
||||
import functools
|
||||
|
||||
from . import ifcopenshell_wrapper
|
||||
from . import settings
|
||||
|
||||
try:
|
||||
import logging
|
||||
@@ -135,9 +136,21 @@ class entity_instance(object):
|
||||
self.wrapped_data.get_argument(idx), self.wrapped_data.file
|
||||
)
|
||||
elif attr_cat == INVERSE:
|
||||
return entity_instance.wrap_value(
|
||||
vs = entity_instance.wrap_value(
|
||||
self.wrapped_data.get_inverse(name), self.wrapped_data.file
|
||||
)
|
||||
if settings.unpack_non_aggregate_inverses:
|
||||
schema_name = self.wrapped_data.is_a(True).split(".")[0]
|
||||
ent = ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(
|
||||
self.is_a()
|
||||
)
|
||||
inv = [i for i in ent.all_inverse_attributes() if i.name() == name][0]
|
||||
if (inv.bound1(), inv.bound2()) == (-1, -1):
|
||||
if vs:
|
||||
vs = vs[0]
|
||||
else:
|
||||
vs = None
|
||||
return vs
|
||||
|
||||
# derived attribute perhaps?
|
||||
schema_name = self.wrapped_data.is_a(True).split(".")[0]
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2021 Thomas Krijnen <thomas@aecgeeks.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
When true return inverses without an aggregate specifier as a single
|
||||
element or None. Example:
|
||||
|
||||
>>> import ifcopenshell
|
||||
>>> f = ifcopenshell.file(schema='ifc2x3')
|
||||
>>> f.createIfcGroup()
|
||||
#1=IfcGroup($,$,$,$,$)
|
||||
>>> f.createIfcRelAssignsToGroup(RelatingGroup=f[1])
|
||||
#2=IfcRelAssignsToGroup($,$,$,$,$,$,#1)
|
||||
>>> f[1].IsGroupedBy
|
||||
(#2=IfcRelAssignsToGroup($,$,$,$,$,$,#1),)
|
||||
>>> ifcopenshell.settings.unpack_non_aggregate_inverses = True
|
||||
>>> f[1].IsGroupedBy
|
||||
#2=IfcRelAssignsToGroup($,$,$,$,$,$,#1)
|
||||
"""
|
||||
|
||||
unpack_non_aggregate_inverses = False
|
||||
Reference in New Issue
Block a user