mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
typing
This commit is contained in:
@@ -15,9 +15,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def add_style(file, name=None, ifc_class="IfcSurfaceStyle") -> None:
|
||||
def add_style(
|
||||
file: ifcopenshell.file, name: Optional[str] = None, ifc_class="IfcSurfaceStyle"
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Add a new presentation style
|
||||
|
||||
A presentation style is a container of visual settings (called
|
||||
@@ -54,8 +58,10 @@ def add_style(file, name=None, ifc_class="IfcSurfaceStyle") -> None:
|
||||
# Create a new surface style
|
||||
style = ifcopenshell.api.run("style.add_style", model)
|
||||
"""
|
||||
settings = {"name": name, "ifc_class": ifc_class}
|
||||
|
||||
if settings["ifc_class"] == "IfcSurfaceStyle":
|
||||
kwargs = {"Name": name}
|
||||
if ifc_class == "IfcSurfaceStyle":
|
||||
# Name is filled out because Revit treats this incorrectly as the material name
|
||||
return file.createIfcSurfaceStyle(settings["name"], "BOTH")
|
||||
kwargs["Side"] = "BOTH"
|
||||
|
||||
return file.create_entity(ifc_class, **kwargs)
|
||||
|
||||
@@ -18,9 +18,15 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
def add_surface_style(file, style=None, ifc_class="IfcSurfaceStyleShading", attributes=None) -> None:
|
||||
def add_surface_style(
|
||||
file: ifcopenshell.file,
|
||||
style: ifcopenshell.entity_instance,
|
||||
ifc_class: str = "IfcSurfaceStyleShading",
|
||||
attributes: Optional[dict[str, Any]] = None,
|
||||
) -> None:
|
||||
"""Adds a new presentation item to a surface style
|
||||
|
||||
A surface style can have multiple different types of presentation items
|
||||
|
||||
@@ -15,18 +15,29 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
|
||||
|
||||
def add_surface_textures(file, material=None, uv_maps=None, textures=None) -> None:
|
||||
def add_surface_textures(
|
||||
file: ifcopenshell.entity_instance,
|
||||
material: Optional[bpy.types.Material] = None,
|
||||
textures: Optional[list[dict]] = None,
|
||||
uv_maps: Optional[list[ifcopenshell.entity_instance]] = None,
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Add surface texture based on a Blender material definition or texture data.
|
||||
|
||||
Either `material` or `textures` should be provided.
|
||||
|
||||
:param material: The Blender material definition with a node tree that
|
||||
is compatible with glTF. See one of the valid combinations here:
|
||||
https://docs.blender.org/manual/en/dev/addons/import_export/scene_gltf2.html
|
||||
:type material: bpy.types.Material
|
||||
:type material: bpy.types.Material, optional
|
||||
:param uv_maps: A list of IfcIndexedTextureMap for any
|
||||
IfcTessellatedFaceSets that the representation has, obtained from
|
||||
the HasTextures attribute.
|
||||
@@ -44,7 +55,7 @@ def add_surface_textures(file, material=None, uv_maps=None, textures=None) -> No
|
||||
based on geometry);
|
||||
* `Camera` - IfcTextureCoordinateGenerator with mode COORD_EYE (autogenerated UV
|
||||
based on camera position)
|
||||
:type textures: list[dict]
|
||||
:type textures: list[dict], optional
|
||||
:return: A list of IfcImageTexture
|
||||
:rtype: list[ifcopenshell.entity_instance]
|
||||
"""
|
||||
|
||||
@@ -22,7 +22,11 @@ import ifcopenshell.util.element
|
||||
|
||||
|
||||
def assign_material_style(
|
||||
file, material=None, style=None, context=None, should_use_presentation_style_assignment=False
|
||||
file: ifcopenshell.file,
|
||||
material: ifcopenshell.entity_instance,
|
||||
style: ifcopenshell.entity_instance,
|
||||
context: ifcopenshell.entity_instance,
|
||||
should_use_presentation_style_assignment: bool = False,
|
||||
) -> None:
|
||||
"""Assigns a style to a material
|
||||
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def assign_representation_styles(
|
||||
file,
|
||||
shape_representation=None,
|
||||
styles=None,
|
||||
replace_previous_same_type_style=True,
|
||||
should_use_presentation_style_assignment=False,
|
||||
) -> None:
|
||||
file: ifcopenshell.file,
|
||||
shape_representation: ifcopenshell.entity_instance,
|
||||
styles: list[ifcopenshell.entity_instance],
|
||||
replace_previous_same_type_style: bool = True,
|
||||
should_use_presentation_style_assignment: bool = False,
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Assigns a style directly to an object representation
|
||||
|
||||
A style may either be assigned directly to an object's representation,
|
||||
@@ -56,7 +57,7 @@ def assign_representation_styles(
|
||||
that this is no longer a valid IFC. Blame Autodesk.
|
||||
:type should_use_presentation_style_assignment: bool
|
||||
:return: List of created IfcStyledItems
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
:rtype: list[ifcopenshell.entity_instance]
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_presentation_style(file, style=None, attributes=None) -> None:
|
||||
def edit_presentation_style(
|
||||
file: ifcopenshell.file, style: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcPresentationStyle
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +30,7 @@ def edit_presentation_style(file, style=None, attributes=None) -> None:
|
||||
:param style: The IfcPresentationStyle entity you want to edit
|
||||
:type style: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_surface_style(file, style=None, attributes=None) -> None:
|
||||
def edit_surface_style(
|
||||
file: ifcopenshell.file, style: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcPresentationItem
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -34,7 +38,7 @@ def edit_surface_style(file, style=None, attributes=None) -> None:
|
||||
:param style: The IfcPresentationStyle entity you want to edit
|
||||
:type style: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def remove_style(file, style=None) -> None:
|
||||
def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a presentation style
|
||||
|
||||
All of the presentation items of the style will also be removed.
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def remove_styled_representation(file, representation=None) -> None:
|
||||
def remove_styled_representation(file: ifcopenshell.file, representation: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a styled representation
|
||||
|
||||
Styled representations are typically associated with materials. This
|
||||
|
||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def remove_surface_style(file, style=None) -> None:
|
||||
def remove_surface_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a presentation item from a presentation style
|
||||
|
||||
:param style: The IfcPresentationItem to remove.
|
||||
|
||||
@@ -18,9 +18,16 @@
|
||||
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def unassign_material_style(file, material=None, style=None, context=None) -> None:
|
||||
def unassign_material_style(
|
||||
file: ifcopenshell.file,
|
||||
material: ifcopenshell.entity_instance,
|
||||
style: ifcopenshell.entity_instance,
|
||||
context: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
"""Unassigns a style to a material
|
||||
|
||||
This does the inverse of assign_material_style.
|
||||
|
||||
@@ -15,10 +15,14 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def unassign_representation_styles(
|
||||
file, shape_representation=None, styles=None, should_use_presentation_style_assignment=False
|
||||
file: ifcopenshell.file,
|
||||
shape_representation: ifcopenshell.entity_instance,
|
||||
styles: list[ifcopenshell.entity_instance],
|
||||
should_use_presentation_style_assignment: bool = False,
|
||||
) -> None:
|
||||
"""Unassigns styles directly assigned to an object representation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user