CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.23k stars 294 forks source link

Simple combination of some ellipses and extrude eats memory and hangs app #1488

Open sadr0b0t opened 10 months ago

sadr0b0t commented 10 months ago

Hello,

This simple code being ran from CQ-Editor eats about 2Gb of memory (from 3.4 to 5.4Gb), cpu 100% and hangs app for about a minute or so. The app did terminate when I first saw that, but it was the os who killed it because of memory consumption. If I give enough memory, it would finally render the model after about a minute.

import cadquery as cq
result2 = (
    cq.Workplane("XY")
    .ellipse(30, 25).ellipse(27, 22).extrude(6)
    .ellipse(30, 25).extrude(6)
)

Just paste code to CQ-Editor and press render. It happens all of the time.

Снимок экрана от 2024-01-09 19-41-51 Снимок экрана от 2024-01-09 19-42-49 Снимок экрана от 2024-01-09 19-43-29

I have made some experiments and it seems that this is some kind of lucky magic combination or figures, operations and numbers. For example, it won't hang in this way:

result10 = (
    cq.Workplane("XY")
    .ellipse(10,10).ellipse(8,8).extrude(6)
    .ellipse(10,10).extrude(6)
)

also won't hang in this ways:

result3 = (
    cq.Workplane("XY")
    .ellipse(30, 25).ellipse(27, 22).extrude(6)
    .ellipse(30, 26).extrude(6)
)

result5 = (
    cq.Workplane("XY")
    .ellipse(30, 25).extrude(6)
    .ellipse(30, 25).extrude(6)
)

result5 = (
    cq.Workplane("XY")
    .ellipse(10, 25).ellipse(27, 22).extrude(6)
    .ellipse(10, 25).extrude(6)
)

result9 = (
    cq.Workplane("XY")
    .ellipse(26, 25).ellipse(27, 22).extrude(6)
    .ellipse(26, 25).extrude(6)
)

it would also hang in this way but for much less time:

result4 = (
    cq.Workplane("XY")
    .ellipse(30, 25).ellipse(27, 22)
    .ellipse(30, 25).extrude(6)
)

even less time to hang:

result6 = (
    cq.Workplane("XY")
    .ellipse(31, 25).ellipse(27, 22).extrude(6)
    .ellipse(31, 25).extrude(6)
)

won't hang, but would draw nothing:

result7 = (
    cq.Workplane("XY")
    .ellipse(27, 25).ellipse(27, 22).extrude(6)
    .ellipse(27, 25).extrude(6)
)
lorenzncode commented 10 months ago

Try relaxing the 3D Viewer tolerances:

cq-editor_prefs_deviation

See also duplicate: https://github.com/CadQuery/CQ-editor/issues/384

adam-urbanczyk commented 10 months ago

I cannot reproduce. BTW you probably wanted:

import cadquery as cq
result2 = (
    cq.Workplane("XY")
    .ellipse(30, 25).ellipse(27, 22)
    .extrude(6)
    .faces('>Z')
    .ellipse(30, 25).extrude(6)
)
sadr0b0t commented 10 months ago

BTW you probably wanted:

yes, I have already drawn what I wanted in similar way, but one can press "render" when design syntax "compiles", but has such logical errors, and receive hang or killed app.