MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / create_entity

Function create_entity

src/ifcopenshell-python/ifcopenshell/__init__.py:217–241  ·  view source on GitHub ↗

Creates a new IFC entity that does not belong to an IFC file object Note that it is more common to create entities within a existing file object. See :meth:`ifcopenshell.file.create_entity`. :param type: Case insensitive name of the IFC class :param schema: The IFC schema identifie

(type: str, schema: str = "IFC4", *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

215
216
217def create_entity(type: str, schema: str = "IFC4", *args: Any, **kwargs: Any) -> entity_instance:
218 """Creates a new IFC entity that does not belong to an IFC file object
219
220 Note that it is more common to create entities within a existing file
221 object. See :meth:`ifcopenshell.file.create_entity`.
222
223 :param type: Case insensitive name of the IFC class
224 :param schema: The IFC schema identifier
225 :param args: The positional arguments of the IFC class
226 :param kwargs: The keyword arguments of the IFC class
227 :returns: An entity instance
228
229 Example:
230
231 .. code:: python
232
233 person = ifcopenshell.create_entity("IfcPerson") # #0=IfcPerson($,$,$,$,$,$,$,$)
234 model = ifcopenshell.file()
235 model.add(person) # #1=IfcPerson($,$,$,$,$,$,$,$)
236 """
237 e = entity_instance((schema, type))
238 attrs = list(enumerate(args)) + [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
239 for idx, arg in attrs:
240 e[idx] = arg
241 return e
242
243
244def register_schema(schema: ifcopenshell.express.schema_class.SchemaClass) -> None:

Callers

nothing calls this directly

Calls 2

entity_instanceClass · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected