ansys / pyansys-geometry

A Python wrapper for Ansys Geometry Services
https://geometry.docs.pyansys.com/
MIT License
38 stars 12 forks source link

Option multi_colors incorrectly applied in PyGeometry script #1467

Open NMLDNV opened 7 hours ago

NMLDNV commented 7 hours ago

🔍 Before submitting the issue

🐞 Description of the bug

The script below generates 10 bodies (layers). The option multi_colors is set to True and 10 bodies with 10 different colors are expected. However, only two different colors (orange and green) can be seen:

from pint import Quantity

from ansys.geometry.core import launch_modeler
from ansys.geometry.core.math import UNITVECTOR3D_Z, Point2D
from ansys.geometry.core.misc import UNITS
from ansys.geometry.core.sketch import Sketch

sketch = Sketch()

(
    sketch.segment(Point2D([0, 0], unit=UNITS.mm), Point2D([40, 1], unit=UNITS.mm), "LowerEdge")
      .arc_to_point(Point2D([41.5, 2.5], unit=UNITS.mm), Point2D([40, 2.5], unit=UNITS.mm), tag="SupportedCorner")
      .segment_to_point(Point2D([41.5, 5], unit=UNITS.mm))
      .arc_to_point(Point2D([43, 6.5], unit=UNITS.mm), Point2D([43, 5], unit=UNITS.mm), True)
      .segment_to_point(Point2D([55, 6.5], unit=UNITS.mm))
      .arc_to_point(Point2D([56.5, 8], unit=UNITS.mm), Point2D([55, 8], unit=UNITS.mm))
      .segment_to_point(Point2D([56.5, 35], unit=UNITS.mm))
      .arc_to_point(Point2D([55, 36.5], unit=UNITS.mm), Point2D([55, 35], unit=UNITS.mm))
      .segment_to_point(Point2D([0, 36.5], unit=UNITS.mm))
      .segment_to_point(Point2D([0, 0], unit=UNITS.mm))
      .circle(Point2D([4, 4], UNITS.mm), Quantity(1.5, UNITS.mm), "Anchor1")
      .circle(Point2D([51, 34.5], UNITS.mm), Quantity(1.5, UNITS.mm), "Anchor2")
)

#sketch.plot()
modeler = launch_modeler()
print(modeler)

design = modeler.create_design("ExtrudedBoardProfile")

layers = []
layer_thickness = Quantity(0.20, UNITS.mm)
for layer_index in range(10):
    layers.append(design.extrude_sketch(f"BoardLayer_{layer_index}", sketch, layer_thickness))
    sketch.translate_sketch_plane_by_distance(UNITVECTOR3D_Z, layer_thickness)

board_named_selection = design.create_named_selection("FullBoard", bodies=layers)
print("Layers: "+str(len(layers)))
design.plot(multi_colors=True)

📝 Steps to reproduce

Just execute posted in the Description section

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

v2024R1 and v2024R2

🐍 Which Python version are you using?

3.10

📦 Installed packages

aiohappyeyeballs==2.4.2
aiohttp==3.10.8
aiosignal==1.3.1
ansys-api-dbu==0.3.4
ansys-api-geometry==0.4.8
ansys-geometry-core==0.7.2
ansys-tools-path==0.6.0
ansys-tools-visualization-interface==0.4.4
appdirs==1.4.4
async-timeout==4.0.3
attrs==24.2.0
beartype==0.18.5
certifi==2024.8.30
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
contourpy==1.3.0
cycler==0.12.1
flexcache==0.3
flexparser==0.3.1
fonttools==4.54.1
frozenlist==1.4.1
grpcio==1.66.2
grpcio-health-checking==1.66.2
idna==3.10
kiwisolver==1.4.7
matplotlib==3.9.2
more-itertools==10.5.0
msgpack==1.1.0
multidict==6.1.0
numpy==2.1.1
packaging==24.1
pillow==10.4.0
Pint==0.24.3
platformdirs==4.3.6
pooch==1.8.2
protobuf==5.27.2
pyparsing==3.1.4
python-dateutil==2.9.0.post0
pyvista==0.44.1
requests==2.32.3
scipy==1.14.1
scooby==0.10.0
semver==3.0.2
six==1.16.0
trame==3.6.5
trame-client==3.3.2
trame-server==3.2.3
trame-vtk==2.8.10
trame-vuetify==2.7.1
typing_extensions==4.12.2
urllib3==2.2.3
vtk==9.3.1
websockets==13.1
wslink==2.2.1
yarl==1.13.1
RobPasMue commented 7 hours ago

Hi @NMLDNV - thanks for opening this issue! As reported internally, this is happening and it should be handled properly. Investigation going on. Assigning to me.