mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
typing
This commit is contained in:
@@ -16,13 +16,18 @@
|
||||
# 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.util.element
|
||||
import ifcopenshell.util.unit
|
||||
import ifcopenshell.util.placement
|
||||
from mathutils import Matrix # For now, we depend on Blender
|
||||
import bpy.types
|
||||
|
||||
|
||||
def create_axis_curve(file, axis_curve=None, grid_axis=None) -> None:
|
||||
def create_axis_curve(
|
||||
file: ifcopenshell.file, axis_curve: bpy.types.Object, grid_axis: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
"""Adds curve geometry to a grid axis to represent the axis extents
|
||||
|
||||
This currently depends on the Blender geometry kernel to function.
|
||||
|
||||
@@ -15,9 +15,17 @@
|
||||
#
|
||||
# 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, Literal
|
||||
|
||||
|
||||
def create_grid_axis(file, axis_tag=None, same_sense=None, uvw_axes=None, grid=None) -> None:
|
||||
def create_grid_axis(
|
||||
file: ifcopenshell.file,
|
||||
grid: ifcopenshell.entity_instance,
|
||||
axis_tag: str = "A",
|
||||
same_sense: bool = True,
|
||||
uvw_axes: Literal["UAxes", "VAxes", "WAxes"] = "UAxes",
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new grid axis to a grid
|
||||
|
||||
An IFC grid will typically have a minimum of two axes which will be
|
||||
@@ -66,17 +74,9 @@ def create_grid_axis(file, axis_tag=None, same_sense=None, uvw_axes=None, grid=N
|
||||
axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
axis_tag="1", uvw_axes="VAxes", grid=grid)
|
||||
"""
|
||||
settings = {
|
||||
"axis_tag": axis_tag or "A",
|
||||
"same_sense": same_sense or True,
|
||||
"uvw_axes": uvw_axes or "UAxes", # Choose which axes
|
||||
"grid": grid,
|
||||
}
|
||||
|
||||
element = file.create_entity(
|
||||
"IfcGridAxis", **{"AxisTag": settings["axis_tag"], "SameSense": settings["same_sense"]}
|
||||
)
|
||||
axes = list(getattr(settings["grid"], settings["uvw_axes"]) or [])
|
||||
element = file.create_entity("IfcGridAxis", **{"AxisTag": axis_tag, "SameSense": same_sense})
|
||||
axes = list(getattr(grid, uvw_axes) or [])
|
||||
axes.append(element)
|
||||
setattr(settings["grid"], settings["uvw_axes"], axes)
|
||||
setattr(grid, uvw_axes, axes)
|
||||
return element
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def remove_grid_axis(file, axis=None) -> None:
|
||||
def remove_grid_axis(file: ifcopenshell.file, axis: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a grid axis from a grid
|
||||
|
||||
:param axis: The IfcGridAxis you want to remove.
|
||||
@@ -43,9 +43,8 @@ def remove_grid_axis(file, axis=None) -> None:
|
||||
# Let's remove it!
|
||||
ifcopenshell.api.run("grid.remove_grid_axis", model, axis=axis_2)
|
||||
"""
|
||||
settings = {"axis": axis}
|
||||
|
||||
if len(file.get_inverse(settings["axis"].AxisCurve)) == 1:
|
||||
ifcopenshell.util.element.remove_deep(file, settings["axis"].AxisCurve)
|
||||
file.remove(settings["axis"].AxisCurve)
|
||||
file.remove(settings["axis"])
|
||||
axis_curve = axis.AxisCurve
|
||||
if len(file.get_inverse(axis_curve)) == 1:
|
||||
ifcopenshell.util.element.remove_deep(file, axis_curve)
|
||||
file.remove(axis_curve)
|
||||
file.remove(axis)
|
||||
|
||||
Reference in New Issue
Block a user