purge cost schedules

This commit is contained in:
Sigma Dimensions (Yass)
2023-09-18 20:20:23 +01:00
parent a251816de0
commit 145f601a2e
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
class Usecase:
def __init__(self, file, cost_schedule=None):
@@ -42,4 +44,13 @@ class Usecase:
def execute(self):
# TODO: do a deep purge
for inverse in self.file.get_inverse(self.settings["cost_schedule"]):
if inverse.is_a("IfcRelAssignsToControl"):
[
ifcopenshell.api.run(
"sequence.remove_cost_item", self.file, task=related_object
)
for related_object in inverse.RelatedObjects
if related_object.is_a("IfcCostItem")
]
self.file.remove(self.settings["cost_schedule"])