mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Reuse assign_control instead of creating IfcRelAssignsToControls
This commit is contained in:
@@ -16,9 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import ifcopenshell.api.control
|
||||||
import ifcopenshell.api.root
|
import ifcopenshell.api.root
|
||||||
import ifcopenshell.api.nest
|
import ifcopenshell.api.nest
|
||||||
import ifcopenshell.api.owner
|
|
||||||
import ifcopenshell.guid
|
import ifcopenshell.guid
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -59,15 +59,7 @@ def add_cost_item(
|
|||||||
cost_item_ = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
|
cost_item_ = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
|
||||||
|
|
||||||
if cost_schedule:
|
if cost_schedule:
|
||||||
file.create_entity(
|
ifcopenshell.api.control.assign_control(file, cost_schedule, cost_item_)
|
||||||
"IfcRelAssignsToControl",
|
|
||||||
**{
|
|
||||||
"GlobalId": ifcopenshell.guid.new(),
|
|
||||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
|
||||||
"RelatedObjects": [cost_item_],
|
|
||||||
"RelatingControl": cost_schedule,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
elif cost_item:
|
elif cost_item:
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item_], relating_object=cost_item)
|
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item_], relating_object=cost_item)
|
||||||
return cost_item_
|
return cost_item_
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import ifcopenshell.api.control
|
||||||
import ifcopenshell.api.root
|
import ifcopenshell.api.root
|
||||||
import ifcopenshell.api.nest
|
import ifcopenshell.api.nest
|
||||||
import ifcopenshell.api.owner
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.guid
|
import ifcopenshell.guid
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@@ -139,15 +139,7 @@ def add_task(
|
|||||||
task.Identification = identification
|
task.Identification = identification
|
||||||
task.IsMilestone = False
|
task.IsMilestone = False
|
||||||
if work_schedule:
|
if work_schedule:
|
||||||
file.create_entity(
|
ifcopenshell.api.control.assign_control(file, work_schedule, task)
|
||||||
"IfcRelAssignsToControl",
|
|
||||||
**{
|
|
||||||
"GlobalId": ifcopenshell.guid.new(),
|
|
||||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
|
||||||
"RelatedObjects": [task],
|
|
||||||
"RelatingControl": work_schedule,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
elif parent_task:
|
elif parent_task:
|
||||||
rel = ifcopenshell.api.nest.assign_object(
|
rel = ifcopenshell.api.nest.assign_object(
|
||||||
file,
|
file,
|
||||||
|
|||||||
Reference in New Issue
Block a user