Skip to content

Commit

Permalink
FEAT: Create equationbased surface (#5038)
Browse files Browse the repository at this point in the history
Co-authored-by: ricrag <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent d198400 commit 6f29994
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,3 +2017,10 @@ def test_93_import_discovery(self):
assert self.aedtapp.modeler.import_discovery_model(self.discovery_file)
assert self.aedtapp.modeler.objects
assert self.aedtapp.modeler.solid_bodies

def test_94_create_equationbased_surface(self):
self.aedtapp.insert_design("Equations_surf")
surf = self.aedtapp.modeler.create_equationbased_surface(
x_uv="(sin(_v*2*pi)^2+1.2)*cos(_u*2*pi)", y_uv="(sin(_v*2*pi)^2+1.2)*sin(_u*2*pi)", z_uv="_v*2"
)
assert surf.name in self.aedtapp.modeler.sheet_names
86 changes: 86 additions & 0 deletions pyaedt/modeler/cad/Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,92 @@ def create_equationbased_curve(self, x_t=0, y_t=0, z_t=0, t_start=0, t_end=1, nu
new_name = self.oeditor.CreateEquationCurve(vArg1, vArg2)
return self._create_object(new_name, **kwargs)

# fmt: off
@pyaedt_function_handler()
def create_equationbased_surface(self, x_uv=0, y_uv=0, z_uv=0, u_start=0, u_end=1, v_start=0, v_end=1,
name=None, **kwargs): # fmt: on
"""Create an equation-based surface.
Parameters
----------
x_uv : str or float
Expression for the X-component of the surface as a function of ``"_u,_v"``.
For example, ``"cos(_u) * sin(_v)"``.
y_uv : str or float
Expression for the Y-component of the surface as a function of ``"_u,_v"``
z_uv : str or float
Expression for the Z-component of the surface as a function of ``"_u,_v"``
u_start : str or float
Starting value of the parameter ``"_u"``.
u_end : str or float
Ending value of the parameter ``"_u"``.
v_start : str or float
Starting value of the parameter ``"_v"``.
v_end : str or float
Ending value of the parameter ``"_v"``.
name : str, optional
Name of the created surface in the 3D modeler. The default is ``None``,
in which case the default name is assigned.
**kwargs : optional
Additional keyword arguments may be passed when creating the primitive to set properties. See
``pyaedt.modeler.cad.object3d.Object3d`` for more details.
Returns
-------
:class:`pyaedt.modeler.cad.object3d.Object3d`
3D object.
References
----------
>>> oEditor.CreateEquationSurface
Examples
--------
The optional parameter ``matname`` allows you to set the material name.
The optional parameter ``name`` allows you to assign a name to the surface.
This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D,
and Mechanical.
>>> from pyaedt import Hfss
>>> aedtapp = Hfss()
>>> surf = aedtapp.modeler.create_equationbased_surface(x_uv='(cos(_v)+2)*cos(_u)',
... y_uv='(cos(_v)+2)*sin(_u)',
... z_uv='sin(_v)',
... u_start=0,
... u_end='2*pi',
... v_start=0,
... v_end='2*pi'
... )
"""

vArg1 = [
"NAME:EquationBasedSurfaceParameters",
"XuvFunction:=",
str(x_uv),
"YuvFunction:=",
str(y_uv),
"ZuvFunction:=",
str(z_uv),
"uStart:=",
str(u_start),
"uEnd:=",
str(u_end),
"vStart:=",
str(v_start),
"vEnd:=",
str(v_end),
"Version:=",
1,
]

vArg2 = self._default_object_attributes(name)

new_name = self.oeditor.CreateEquationSurface(vArg1, vArg2)
return self._create_object(new_name, **kwargs)

# fmt: off
@pyaedt_function_handler(polyline_name="assignment", position="origin", num_thread="turns")
def create_helix(self, assignment, origin, x_start_dir, y_start_dir, z_start_dir, turns=1,
Expand Down

0 comments on commit 6f29994

Please sign in to comment.