mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -17,43 +17,48 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
def unassign_representation_styles(
|
||||
file, shape_representation=None, styles=None, should_use_presentation_style_assignment=False
|
||||
) -> None:
|
||||
"""Unassigns styles directly assigned to an object representation
|
||||
|
||||
This does the inverse of assign_representation_styles.
|
||||
|
||||
:param shape_representation: The IfcShapeRepresentation of the object
|
||||
that you want to unassign styles from.
|
||||
:type shape_representation: ifcopenshell.entity_instance
|
||||
:param styles: A list of presentation styles, typically IfcSurfaceStyle.
|
||||
The number of items in the list should correlate with the number of
|
||||
items in the shape_representation's Items attribute. If you have
|
||||
more items than styles, the last style is used.
|
||||
:type styles: list[ifcopenshell.entity_instance]
|
||||
:param should_use_presentation_style_assignment: This is a technical
|
||||
detail to accomodate a bug in Revit. This should always be left as
|
||||
the default of False, unless you are finding that colours aren't
|
||||
showing up in Revit. In that case, set it to True, but keep in mind
|
||||
that this is no longer a valid IFC. Blame Autodesk.
|
||||
:type should_use_presentation_style_assignment: bool
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("style.unassign_representation_styles", model,
|
||||
shape_representation=representation, styles=[style])
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
usecase.settings = {
|
||||
"shape_representation": shape_representation,
|
||||
"styles": styles or [],
|
||||
"should_use_presentation_style_assignment": should_use_presentation_style_assignment,
|
||||
}
|
||||
return usecase.execute()
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, shape_representation=None, styles=None, should_use_presentation_style_assignment=False):
|
||||
"""Unassigns styles directly assigned to an object representation
|
||||
|
||||
This does the inverse of assign_representation_styles.
|
||||
|
||||
:param shape_representation: The IfcShapeRepresentation of the object
|
||||
that you want to unassign styles from.
|
||||
:type shape_representation: ifcopenshell.entity_instance
|
||||
:param styles: A list of presentation styles, typically IfcSurfaceStyle.
|
||||
The number of items in the list should correlate with the number of
|
||||
items in the shape_representation's Items attribute. If you have
|
||||
more items than styles, the last style is used.
|
||||
:type styles: list[ifcopenshell.entity_instance]
|
||||
:param should_use_presentation_style_assignment: This is a technical
|
||||
detail to accomodate a bug in Revit. This should always be left as
|
||||
the default of False, unless you are finding that colours aren't
|
||||
showing up in Revit. In that case, set it to True, but keep in mind
|
||||
that this is no longer a valid IFC. Blame Autodesk.
|
||||
:type should_use_presentation_style_assignment: bool
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("style.unassign_representation_styles", model,
|
||||
shape_representation=representation, styles=[style])
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"shape_representation": shape_representation,
|
||||
"styles": styles or [],
|
||||
"should_use_presentation_style_assignment": should_use_presentation_style_assignment,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
if not self.settings["styles"]:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user