mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 18:16:20 +00:00
Update code_examples.rst
Added example to iterate through entire project.
This commit is contained in:
committed by
Thomas Krijnen
parent
e39d62b35a
commit
fef6ef76ed
@@ -17,21 +17,22 @@ functions, check out the API Reference.
|
|||||||
Get all entites (STEP ID items)
|
Get all entites (STEP ID items)
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
IFC file opened through IfcOpenShell is iterable. This means you can get all entities (all STEP ID items) that occurs in the file with a simple loop.
|
|
||||||
|
IFC file opened through IfcOpenShell is iterable. This means you can get all instance (all STEP ID items) that occurs in the file with a simple loop.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
for entity in model:
|
for inst in model:
|
||||||
# It prints out entire entity as it appears in IFC file, e.g
|
# It prints out entire entity as it appears in IFC file, e.g
|
||||||
print("The STEP entity is: ", entity)
|
print("The STEP entity is: ", inst)
|
||||||
# You can get info about attributes of an instance as you normally would, e.g. name, type, get_info()
|
# You can get info about attributes of an instance as you normally would, e.g. name, type, get_info()
|
||||||
print(entity.get_info())
|
print(inst.get_info())
|
||||||
# Get entity type
|
# Get instance type
|
||||||
print(entity.is_a())
|
print(inst.is_a())
|
||||||
# Get entity name. IF statement is necessary to ensure that the entity is actual instance such as walls, properties, tasks etc.
|
# Get instance name. To ensure you get instances that have attribute Name, simple IF statement will suffice.
|
||||||
# For more information check submodule: ifcopenshell.entity_instance
|
# For more information check submodule: ifcopenshell.entity_instance
|
||||||
if isinstance(entity, ifcopenshell.ifcopenshell_wrapper.entity_instance):
|
if hasattr(inst, "Name"):
|
||||||
print(entity.Name)
|
print(inst.Name)
|
||||||
|
|
||||||
Get all wall types
|
Get all wall types
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user