From d720f51e4ecac66b588f84e3ce165dbdbc29917d Mon Sep 17 00:00:00 2001 From: spn Date: Mon, 20 Oct 2025 15:42:54 -0700 Subject: [PATCH 1/7] Property added to set_geometries --- src/ansys/speos/core/opt_prop.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index efa698f3e..87532c30f 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -267,6 +267,7 @@ def set_volume_library(self, path: str) -> OptProp: self._vop_template.library.material_file_uri = path return self + @property def set_geometries( self, geometries: Optional[List[Union[GeoRef, body.Body, face.Face, part.Part.SubPart]]] = None, From eaad41f40709c2079620b5adf45cd0cbc2d9015c Mon Sep 17 00:00:00 2001 From: Sean Patterson <69062333+spatterswork@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:24:13 -0700 Subject: [PATCH 2/7] Update src/ansys/speos/core/opt_prop.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Thöne <86405327+StefanThoene@users.noreply.github.com> --- src/ansys/speos/core/opt_prop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index 87532c30f..ed27d08b8 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -268,7 +268,7 @@ def set_volume_library(self, path: str) -> OptProp: return self @property - def set_geometries( + def geometries( self, geometries: Optional[List[Union[GeoRef, body.Body, face.Face, part.Part.SubPart]]] = None, ) -> OptProp: From 2de6c1b1d535c7a8eb770a1e86c61cfe26f20613 Mon Sep 17 00:00:00 2001 From: spn Date: Fri, 24 Oct 2025 12:53:27 -0700 Subject: [PATCH 3/7] Property and Setter added to geometries, I know it has errors I am trying to return the property not sure I am doing this correctly --- src/ansys/speos/core/opt_prop.py | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index ed27d08b8..6b5af99d9 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -297,11 +297,47 @@ def geometries( else: msg = f"Type {type(gr)} is not supported as Optical property geometry input." raise TypeError(msg) + + # I a lost here as to how to return this property correctly self._material_instance.geometries.geo_paths[:] = [ gp.to_native_link() for gp in geo_paths ] return self + @geometries.setter + def geometries( + self, + geometries: Optional[List[Union[GeoRef, body.Body, face.Face, part.Part.SubPart]]] = None, + ) -> OptProp: + """Select geometries on which the optical properties will be applied. + + Parameters + ---------- + geometries : List[ansys.speos.core.geo_ref.GeoRef], optional + List of geometries. Giving an empty list means "All geometries" + By default, ``None``, means "no geometry". + + Returns + ------- + ansys.speos.core.opt_prop.OptProp + Optical property. + """ + if geometries is None: + self._material_instance.ClearField("geometries") + else: + geo_paths = [] + for gr in geometries: + if isinstance(gr, GeoRef): + geo_paths.append(gr) + elif isinstance(gr, (face.Face, body.Body, part.Part.SubPart)): + geo_paths.append(gr.geo_path) + else: + msg = f"Type {type(gr)} is not supported as Optical property geometry input." + raise TypeError(msg) + self._material_instance.geometries.geo_paths[:] = [ + gp.to_native_link() for gp in geo_paths + ] + def _to_dict(self) -> dict: out_dict = {} From 891a80c23fdd81b5ff077562eb8fea867c35b724 Mon Sep 17 00:00:00 2001 From: spn Date: Fri, 24 Oct 2025 15:54:54 -0700 Subject: [PATCH 4/7] Property and Setter added to set volume_optic --- src/ansys/speos/core/opt_prop.py | 45 ++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index 6b5af99d9..e30dd883b 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -169,7 +169,49 @@ def set_volume_opaque(self) -> OptProp: self._vop_template.opaque.SetInParent() return self - def set_volume_optic( + @property + def volume_optic( + self, + index: float = 1.5, + absorption: float = 0, + constringence: Optional[float] = None, + ) -> OptProp: + """ + Transparent colorless material without bulk scattering. + + Parameters + ---------- + index : float + Refractive index. + By default, ``1.5``. + absorption : float + Absorption coefficient value. mm-1. + By default, ``0``. + constringence : float, optional + Abbe number. + By default, ``None``, means no constringence. + + Returns + ------- + ansys.speos.core.opt_prop.OptProp + Optical property. + """ + if self._vop_template is None: + self._vop_template = ProtoVOPTemplate( + name=self._name + ".VOP", + description=self._sop_template.description, + metadata=self._sop_template.metadata, + ) + self._vop_template.optic.index = index + self._vop_template.optic.absorption = absorption + if constringence is not None: + self._vop_template.optic.constringence = constringence + else: + self._vop_template.optic.ClearField("constringence") + return self.volume_optic + + @volume_optic.setter + def volume_optic( self, index: float = 1.5, absorption: float = 0, @@ -207,7 +249,6 @@ def set_volume_optic( self._vop_template.optic.constringence = constringence else: self._vop_template.optic.ClearField("constringence") - return self # Deactivated due to a bug on SpeosRPC server side # def set_volume_nonhomogeneous( From d7016dd3eedc21db363179f72ab49b7ffd7d6cf0 Mon Sep 17 00:00:00 2001 From: Sean Patterson <69062333+spatterswork@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:13:30 -0700 Subject: [PATCH 5/7] Update src/ansys/speos/core/opt_prop.py Co-authored-by: Pengyuan LU <89462462+pluAtAnsys@users.noreply.github.com> --- src/ansys/speos/core/opt_prop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index e30dd883b..95060264e 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -349,7 +349,7 @@ def geometries( def geometries( self, geometries: Optional[List[Union[GeoRef, body.Body, face.Face, part.Part.SubPart]]] = None, - ) -> OptProp: + ) -> None: """Select geometries on which the optical properties will be applied. Parameters From 45ab5006ce52f40acd06b6eb25fcab7e8686a629 Mon Sep 17 00:00:00 2001 From: Sean Patterson <69062333+spatterswork@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:16:19 -0700 Subject: [PATCH 6/7] Update src/ansys/speos/core/opt_prop.py Co-authored-by: Pengyuan LU <89462462+pluAtAnsys@users.noreply.github.com> --- src/ansys/speos/core/opt_prop.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index 95060264e..1e1ac84f4 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -311,6 +311,8 @@ def set_volume_library(self, path: str) -> OptProp: @property def geometries( self, + ) -> List: + self, geometries: Optional[List[Union[GeoRef, body.Body, face.Face, part.Part.SubPart]]] = None, ) -> OptProp: """Select geometries on which the optical properties will be applied. From 27aa02e7de6004f441a089436bd49e83ef38d0a0 Mon Sep 17 00:00:00 2001 From: Sean Patterson <69062333+spatterswork@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:16:29 -0700 Subject: [PATCH 7/7] Update src/ansys/speos/core/opt_prop.py Co-authored-by: Pengyuan LU <89462462+pluAtAnsys@users.noreply.github.com> --- src/ansys/speos/core/opt_prop.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ansys/speos/core/opt_prop.py b/src/ansys/speos/core/opt_prop.py index 1e1ac84f4..0132d67cc 100644 --- a/src/ansys/speos/core/opt_prop.py +++ b/src/ansys/speos/core/opt_prop.py @@ -340,8 +340,7 @@ def geometries( else: msg = f"Type {type(gr)} is not supported as Optical property geometry input." raise TypeError(msg) - - # I a lost here as to how to return this property correctly + return self._material_instance.geometries.geo_paths self._material_instance.geometries.geo_paths[:] = [ gp.to_native_link() for gp in geo_paths ]