-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generated construction animations now support animating input product…
… consumptions, movement to/from, and multiple processes per product
- Loading branch information
Showing
4 changed files
with
160 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ifcopenshell | ||
import ifcopenshell.api | ||
|
||
|
||
class Usecase: | ||
def __init__(self, file, **settings): | ||
self.file = file | ||
self.settings = { | ||
"relating_process": None, | ||
"related_object": None, | ||
} | ||
for key, value in settings.items(): | ||
self.settings[key] = value | ||
|
||
def execute(self): | ||
if self.settings["related_object"].HasAssignments: | ||
for assignment in self.settings["related_object"].HasAssignments: | ||
if ( | ||
assignment.is_a("IfclRelAssignsToProcess") | ||
and assignment.RelatingProcess == self.settings["relating_process"] | ||
): | ||
return | ||
|
||
operates_on = None | ||
if self.settings["relating_process"].OperatesOn: | ||
operates_on = self.settings["relating_process"].OperatesOn[0] | ||
|
||
if operates_on: | ||
related_objects = list(operates_on.RelatedObjects) | ||
related_objects.append(self.settings["related_object"]) | ||
operates_on.RelatedObjects = related_objects | ||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": operates_on}) | ||
else: | ||
operates_on = self.file.create_entity( | ||
"IfcRelAssignsToProcess", | ||
**{ | ||
"GlobalId": ifcopenshell.guid.new(), | ||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), | ||
"RelatedObjects": [self.settings["related_object"]], | ||
"RelatingProcess": self.settings["relating_process"], | ||
} | ||
) | ||
return operates_on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import ifcopenshell | ||
import ifcopenshell.api | ||
|
||
|
||
class Usecase: | ||
def __init__(self, file, **settings): | ||
self.file = file | ||
self.settings = { | ||
"relating_process": None, | ||
"related_object": None, | ||
} | ||
for key, value in settings.items(): | ||
self.settings[key] = value | ||
|
||
def execute(self): | ||
for rel in self.settings["related_object"].HasAssignments or []: | ||
if not rel.is_a("IfcRelAssignsToProcess") or rel.RelatingProcess != self.settings["relating_process"]: | ||
continue | ||
if len(rel.RelatedObjects) == 1: | ||
return self.file.remove(rel) | ||
related_objects = list(rel.RelatedObjects) | ||
related_objects.remove(self.settings["related_object"]) | ||
rel.RelatedObjects = related_objects | ||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel}) | ||
return rel |