Skip to main content

create_type

Function create_type 

Source
pub fn create_type(
    tx: &mut Transaction,
    kind: ElementType,
    global_id: &str,
    predefined_type: Option<&str>,
    draft: TypeDraft<'_>,
) -> ElementTypeResult<EntityId>
Expand description

Stage one type definition.

predefined_type must be a token the entity’s own enum declares. A token borrowed from a sibling enum is refused: IfcPumpTypeEnum has no SUBMERSIBLEPUMP member merely because some other pump-like enum does.

§Release

Takes no model, so it writes the catalogue’s IFC4X3 layout with OwnerHistory $, and cannot refuse a model that declares another release. That record is valid in IFC4X3 and, where IFC4 declares the type with the same layout and token, in IFC4; it is never valid IFC2X3, which requires OwnerHistory. Use create_type_in or create_type_with_owner_history to write the model’s declared release.

§Errors

Refuses a malformed GlobalId, a token outside the entity’s enum, a missing predefined type where the schema requires one, USERDEFINED without the fallback attribute, and a slot-6 value of the wrong shape for the entity’s family. A type-specific token outside its enumeration is ElementTypeError::Invalid, one for an attribute the type does not declare ElementTypeError::AuthoringNotInSchema, and USERDEFINED event_trigger_type without user_defined_event_trigger_type is refused (CorrectEventTriggerType). A required attribute left unset, such as IfcDoorType.OperationType or IfcFurnitureType.AssemblyPlace, is ElementTypeError::AuthoringRequired, never written $ (#214). Nothing is staged on an error.