use ifc_model::{Entity, EntityId, Transaction, Value};
use super::guid;
use crate::error::AlignmentError;
use crate::slot;
pub fn linear_element(
tx: &mut Transaction,
global_id: &str,
name: Option<&str>,
placement: Option<EntityId>,
) -> Result<EntityId, AlignmentError> {
const ENTITY: &str = "IFCLINEARELEMENT";
let mut attrs = vec![Value::Null; slot::product::ARITY];
attrs[slot::product::GLOBAL_ID] = guid(ENTITY, global_id)?;
if let Some(name) = name {
attrs[slot::product::NAME] = Value::Text(name.into());
}
if let Some(placement) = placement {
attrs[slot::product::OBJECT_PLACEMENT] = Value::Ref(placement);
}
Ok(tx.create(Entity::new(ENTITY, attrs)))
}
pub fn linear_positioning_element(
tx: &mut Transaction,
global_id: &str,
name: Option<&str>,
placement: EntityId,
) -> Result<EntityId, AlignmentError> {
const ENTITY: &str = "IFCLINEARPOSITIONINGELEMENT";
let mut attrs = vec![Value::Null; slot::product::ARITY];
attrs[slot::product::GLOBAL_ID] = guid(ENTITY, global_id)?;
if let Some(name) = name {
attrs[slot::product::NAME] = Value::Text(name.into());
}
attrs[slot::product::OBJECT_PLACEMENT] = Value::Ref(placement);
Ok(tx.create(Entity::new(ENTITY, attrs)))
}