Replies: 15 comments 15 replies
|
Hi, thanks for the hint. I haven't seen it before. It looks interesting. What are your thoughts about it? On the first glance (from what I could see on the web) my impression was that the openscad integration is far better but the "user interface / api" does not seem to be as enhanced. I'm gonna have a closer look at it. |
|
That's this example with minor changes and it works from openscad import cube, cylinder
def wheel():
return cylinder(r=35, h=15, center=True).rotate([0, 90, 0])
def axle():
a = cylinder(r=10, h=120, center=True).rotate([0, 90, 0])
w1 = wheel().left(70)
w2 = wheel().right(70)
return w1 | w2 | a
def torso():
bottom = cube([100, 250, 50], center=True)
top = cube([80, 100, 60], center=True)
window_cube = cube([200, 55 ,50], center=True).down(10)
top -= (window_cube | window_cube.rotate([0, 0, 90]))
return bottom | top.up(50)
def car():
t = torso()
front_axle = axle().down(20).back(80)
rear_axle = axle().down(20).back(-80)
return t | front_axle | rear_axle
car().show() |
|
I think we have a similar perspective. I think one drawback is that I think it's hard to use pythonscad as python library from outside openscad, right? It's pretty tight couple to the openscad executable I assume. I'm wondering whether it would make sense to implement kind of an intermediate representation interface for openscad that languages (like python) could use. kind of a virtual machine for csg solids..... |
|
it seems there already has been openscadpy several years ago.... |
|
I have seen that, Unfortunately, this project is quite dead. It did not
receive any latest updates of openscad like manifold and others
…On Sun, Dec 15, 2024 at 7:24 PM jeff ***@***.***> wrote:
it seems there already has been openscadpy
<https://github.com/hmeyer/openscadpy> several years ago....
—
Reply to this email directly, view it on GitHub
<#71 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCO4MVGZWDD3VJEV3FS2RL2FXCNXAVCNFSM6AAAAABTOCT6ROVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNJXGM3DQMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@jeff-dh gsohler/openscad#52 |
|
What about this: from solid2 import cube
from openscad import output, scad
def output_solid2(obj):
output(scad(obj.as_scad()))
output_solid2(cube(1).up())That works! SolidPython ontop of pythonscad.... OpenScad is kind of the intermediate representation and pythonscad mimics the vm I was talking about earlier :D |
|
some scad file: use <solidtest.py>;
solidTest();solidtest.py from solid2 import sphere
def solidTest():
from openscad import scad
return scad(sphere(5).as_scad())This does not work, but I assume it should work with little effort |
|
If you have a python file in the same dir, and you include it, and you later update that file, you have to restart OpenSCAD to get the update. |
|
SolidPython ontop of pythonscad.: https://pythonscad.org/shared_designs/ea7907c7a3ee89ac61a86f72351892c1 its a basically just a sphere, but its radius is direction dependent, result supplied by a python function turning it into a nice sharp cornered cuocathaedron. It would be cool if that SolidPython could make openSCAd to do the same, but have small doubts |
from solid2 import polyhedron
from icosphere import icosphere
from inspect import isfunction
def supersphere(r=1, fn=10):
vs, fs = icosphere(fn)
for i, v in enumerate(vs):
if isfunction(r):
vs[i] = v * r(v)
else:
vs[i] = v * r
return polyhedron(vs, fs)
def rfunc(v):
def dot(v1, v2):
return v1[0]*v2[0]+ v1[1]*v2[1] + v1[2]*v2[2]
def mydotmax(v, dirs):
res = 0
for dir in dirs:
res = max(res, abs(dot(v, dir)))
return res
dirs=[[0.0,0.0,1.0],
[1.0,0.0,0.0],
[0.0,1.0,0.0],
[0.5,0.5,0.5],
[0.5,0.5,-0.5],
[0.5,-0.5,0.5],
[0.5,-0.5,-0.5],
]
cf = mydotmax(v, dirs)
return 10/pow(cf,1.5)
supersphere(rfunc, fn=50).save_as_scad() |
|
python interpreter maintains a cache and its preferred over the source
code when not cleared.
you can clear the cache with some python commands
…On Mon, Dec 16, 2024 at 12:19 AM jeff ***@***.***> wrote:
Is it possible that there's one and the same interpreter instance running
all the time?
I had to restart openscad several times to reset the python interpreter
(neccessary because of some python / openscad "compile errors" which seemed
to be stuck in the session....)
is that possible?
—
Reply to this email directly, view it on GitHub
<#71 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCO4MVQXEFWTZITN5ENCTT2FYFB5AVCNFSM6AAAAABTOCT6ROVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNJXGUYTANI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Way cool!
This is basically also what I am doing :)
Having the icosphere algorithm has (only) few advantages over your solution.
i can expand the icosphere to next granularity dependent on the need(not
necessary when absolutely flat)
Also i remember that i put some effort to put the vertices very near to the
resulting edge, so edges would ideally appear exactly sharp and not round
I like your solution, though !
…On Mon, Dec 16, 2024 at 11:10 PM jeff ***@***.***> wrote:
from solid2 import polyhedronfrom icosphere import icospherefrom inspect import isfunction
def supersphere(r=1, fn=10):
vs, fs = icosphere(fn)
for i, v in enumerate(vs):
if isfunction(r):
vs[i] = v * r(v)
else:
vs[i] = v * r
return polyhedron(vs, fs)
def rfunc(v):
def dot(v1, v2):
return v1[0]*v2[0]+ v1[1]*v2[1] + v1[2]*v2[2]
def mydotmax(v, dirs):
res = 0
for dir in dirs:
res = max(res, abs(dot(v, dir)))
return res
dirs=[[0.0,0.0,1.0],
[1.0,0.0,0.0],
[0.0,1.0,0.0],
[0.5,0.5,0.5],
[0.5,0.5,-0.5],
[0.5,-0.5,0.5],
[0.5,-0.5,-0.5],
]
cf = mydotmax(v, dirs)
return 10/pow(cf,1.5)
supersphere(rfunc, fn=50).save_as_scad()
abcdef.png (view on web)
<https://github.com/user-attachments/assets/5e5398f0-a362-4582-a822-6d8dbb4cf3b2>
—
Reply to this email directly, view it on GitHub
<#71 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCO4MQLJBY57DFEWEPPLYL2F5FT7AVCNFSM6AAAAABTOCT6ROVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNJYGYZTSNQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi Jeff,
I've been looking into PythonSCAD lately: https://pythonscad.org/
It seems like they're trying to get a two-way integration between OpenSCAD and Python, instead of write-only. But, having interacted with the developer, I don't think they have much Python experience/expertise. I think they could really use your help.
I was hoping to hear an informed comparison of the two projects, if you know enough about PythonSCAD to compare.
All reactions