ifc_alignment/authoring/
linear.rs1use ifc_model::{Entity, EntityId, Transaction, Value};
12
13use super::guid;
14use crate::error::AlignmentError;
15use crate::slot;
16
17pub fn linear_element(
26 tx: &mut Transaction,
27 global_id: &str,
28 name: Option<&str>,
29 placement: Option<EntityId>,
30) -> Result<EntityId, AlignmentError> {
31 const ENTITY: &str = "IFCLINEARELEMENT";
32 let mut attrs = vec![Value::Null; slot::product::ARITY];
33 attrs[slot::product::GLOBAL_ID] = guid(ENTITY, global_id)?;
34 if let Some(name) = name {
35 attrs[slot::product::NAME] = Value::Text(name.into());
36 }
37 if let Some(placement) = placement {
38 attrs[slot::product::OBJECT_PLACEMENT] = Value::Ref(placement);
39 }
40 Ok(tx.create(Entity::new(ENTITY, attrs)))
41}
42
43pub fn linear_positioning_element(
58 tx: &mut Transaction,
59 global_id: &str,
60 name: Option<&str>,
61 placement: EntityId,
62) -> Result<EntityId, AlignmentError> {
63 const ENTITY: &str = "IFCLINEARPOSITIONINGELEMENT";
64 let mut attrs = vec![Value::Null; slot::product::ARITY];
65 attrs[slot::product::GLOBAL_ID] = guid(ENTITY, global_id)?;
66 if let Some(name) = name {
67 attrs[slot::product::NAME] = Value::Text(name.into());
68 }
69 attrs[slot::product::OBJECT_PLACEMENT] = Value::Ref(placement);
70 Ok(tx.create(Entity::new(ENTITY, attrs)))
71}