How to decrease the time taken for generation of model

68 views
Skip to first unread message

Adhip

unread,
Dec 12, 2023, 2:50:09 AM12/12/23
to CadQuery
Hi!
I have created a very complex design, fully parametric. When I enter values, which are on a higher side, the program takes very long to finish. Any suggestions how can I improve on that?

Adam Urbanczyk

unread,
Dec 13, 2023, 12:02:52 PM12/13/23
to CadQuery
Some ideas:

- work in 2D as long as possible
- avoid boolean ops
- if you must use boolean ops, do not use them in loops
- if possible, use bool ops with glue=True
- turn off clean (set clean=False)

HTH

Adhip

unread,
Dec 27, 2023, 5:31:33 AM12/27/23
to CadQuery
Thanks a lot!

Actually I prepared code which has for loops and creates multiple curves on a plate. The problem I'm facing is, if I run the code the code doesn't create any stl or step file. It works if I have piece of code that creates a particular curve. This curve is not needed but without this the code doesn't run. I feel because of this particular code, the overall speed of code has gone down. Can anyone shed some light to this?

Adam Urbanczyk

unread,
Dec 27, 2023, 12:19:05 PM12/27/23
to CadQuery
You'll need to share the full code or a MRE at least.

Adhip

unread,
Jan 17, 2024, 4:40:40 AM1/17/24
to CadQuery
What is MRE?

Jeremy Wright

unread,
Jan 17, 2024, 7:26:28 AM1/17/24
to Adhip, CadQuery

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/86b0e18f-b701-494a-8b98-da48715ab1cdn%40googlegroups.com.

Adhip

unread,
Jan 23, 2024, 4:46:20 AM1/23/24
to CadQuery
Apart from this, I had one doubt.

for i in range(n): #Left side
    angle = 0
    point=[]
    offpoint=[]
x = i * wavelength / num_points
        y = amplitude * mt.sin(Phasemultiplier *2 * mt.pi * x / wavelength)
        x_new = x
        y_new = y - channel_spacing
        point.append([x, y])
        offpoint.append([x_new,y_new])
    (p,q) = offpoint[-1] #Finding out the last point on the wave
    new = offpoint[::-1] #Reversing the order
plate = plate.polyline(point).lineTo(p,q).polyline(new).close().cutBlind(channel_dep)

Above is this code.
Now, if I keep the cadquery command in For loop, it doesn't work but when I keep it outside, it works. However, I only get the last calculated points instead of given 'n' numbers. Any ideas what to do?


Adhip

unread,
Jan 24, 2024, 8:37:05 AM1/24/24
to CadQuery
The code above was wrong. 

This is the corrected code:
for j in range(m):
    point=[]
    offpoint=[]
    for i in range(num_points): #Left side
        x = i * wavelength / num_points
        y = amplitude * mt.sin(Phasemultiplier *2 * mt.pi * x / wavelength)
        x_new = x
        y_new = y - channel_spacing
        point.append([x, y])
        offpoint.append([x_new,y_new])
    lastPoff1 = offpoint[-1] #Finding out the last point on the wave
    (p,q) = lastPoff1
    new = offpoint[::-1] #Reversing the order
    plate = plate.moveTo(0,o).polyline(point).lineTo(p,q).polyline(new).close().cutBlind(channel_dep)
    o=o+1.56*2

According to my logic, it should create m number of curves but its not. Please help
Reply all
Reply to author
Forward
0 new messages