mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-01 12:40:07 +00:00
ifcopenshell.geom.create_shape - document all return types
This commit is contained in:
@@ -317,7 +317,9 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
return ifcopenshell_wrapper.tree.clash_clearance_many(*args)
|
return ifcopenshell_wrapper.tree.clash_clearance_many(*args)
|
||||||
|
|
||||||
|
|
||||||
def create_shape(settings: settings, inst: entity_instance, repr: Optional[entity_instance] = None) -> ShapeElementType:
|
def create_shape(
|
||||||
|
settings: settings, inst: entity_instance, repr: Optional[entity_instance] = None
|
||||||
|
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.Transformation]:
|
||||||
"""
|
"""
|
||||||
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
Return a geometric representation from STEP-based IFCREPRESENTATIONSHAPE
|
||||||
or
|
or
|
||||||
@@ -326,26 +328,33 @@ def create_shape(settings: settings, inst: entity_instance, repr: Optional[entit
|
|||||||
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
|
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
|
||||||
collection when you access its children. See #1124.
|
collection when you access its children. See #1124.
|
||||||
|
|
||||||
To create a representation for IfcTypeProduct you need to provide use `create_shape(settings, representation)`
|
:return:
|
||||||
(representation is provided as `inst` argument).
|
- `inst` is IfcProduct and `repr` provided / None -> ShapeElementType
|
||||||
|
- `inst` is IfcRepresentation and `repr` is None -> ShapeType
|
||||||
|
- `inst` is IfcPlacement / IfcObjectPlacement -> Transformation
|
||||||
|
- `inst` is IfcTypeProduct and `repr` is None -> None
|
||||||
|
- `inst` is IfcTypeProduct and `repr` is provided -> RuntimeError
|
||||||
|
(for IfcTypeProducts provide just IfcRepresentation as `inst`).
|
||||||
|
|
||||||
example:
|
Example:
|
||||||
|
|
||||||
settings = ifcopenshell.geom.settings()
|
.. code:: python
|
||||||
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
|
|
||||||
|
|
||||||
ifc_file = ifcopenshell.open(file_path)
|
settings = ifcopenshell.geom.settings()
|
||||||
products = ifc_file.by_type("IfcProduct")
|
settings.set(settings.USE_PYTHON_OPENCASCADE, True)
|
||||||
|
|
||||||
for i, product in enumerate(products):
|
ifc_file = ifcopenshell.open(file_path)
|
||||||
if product.Representation is not None:
|
products = ifc_file.by_type("IfcProduct")
|
||||||
try:
|
|
||||||
created_shape = geom.create_shape(settings, inst=product)
|
for i, product in enumerate(products):
|
||||||
shape = created_shape.geometry # see #1124
|
if product.Representation is not None:
|
||||||
shape_gpXYZ = shape.Location().Transformation().TranslationPart() # These are methods of the TopoDS_Shape class from pythonOCC
|
try:
|
||||||
print(shape_gpXYZ.X(), shape_gpXYZ.Y(), shape_gpXYZ.Z()) # These are methods of the gpXYZ class from pythonOCC
|
created_shape = geom.create_shape(settings, inst=product)
|
||||||
except:
|
shape = created_shape.geometry # see #1124
|
||||||
print("Shape creation failed")
|
shape_gpXYZ = shape.Location().Transformation().TranslationPart() # These are methods of the TopoDS_Shape class from pythonOCC
|
||||||
|
print(shape_gpXYZ.X(), shape_gpXYZ.Y(), shape_gpXYZ.Z()) # These are methods of the gpXYZ class from pythonOCC
|
||||||
|
except:
|
||||||
|
print("Shape creation failed")
|
||||||
"""
|
"""
|
||||||
return wrap_shape_creation(
|
return wrap_shape_creation(
|
||||||
settings,
|
settings,
|
||||||
|
|||||||
Reference in New Issue
Block a user