teepee changed the topic of #openscad to: OpenSCAD - The Programmers Solid 3D CAD Modeller | This channel is logged! | Website: http://www.openscad.org/ | FAQ: https://goo.gl/pcT7y3 | Request features / report bugs: https://goo.gl/lj0JRI | Tutorial: https://bit.ly/37P6z0B | Books: https://bit.ly/3xlLcQq | FOSDEM 2020: https://bit.ly/35xZGy6 | Logs: https://bit.ly/32MfbH5
<ali1234> this could even allow me to complete my dream of writing openscad in a blender text data resource attached to an object, and having the resulting 3d mesh instantly appear in the scene viewer
<guso78k> yep possible. did some attempts to run openscad in jupyter. everything but the graphics work :')
<ali1234> i was also thinking about what stealth_ said about syntax
<ali1234> i could not think of a way to make it really work the way openscad does due to pythons (lack of) scoping
<guso78k> IMHO lack of scoping is not a disadvantage, but thats my personal opinion
<guso78k> and yes: there many workarounds for scoped openscad. basically its always recursion.
<ali1234> the best i could come up with is some trick along the lines of "with difference(): cube(); cube(); ..."
<ali1234> but with doesn't create a scope so even this would need extreme inspect magic and probably totally changing how the code gets compiled
<stealth_> you talking about how to have it rendering without having to pass var around? its like how print() puts data into stdout.
<ali1234> it's not like print at all, but yes
<ali1234> this is the idea i had: https://bpa.st/SA6A
<ali1234> but it can't be implemented in a way that won't break with every python update
<stealth_> many ways to go about it, if you have `cube() - cube()` you can stdout the result of it in operator class
<ali1234> python doesn't have operator classes as such
<ali1234> you can't directly override what "-" does, you can only override how individual classes react to it
<ali1234> the main problem is if you have a bare function call like "cube()" then the result just vanishes immediately. it probably still exists in the memory pool but there's no way to retrieve it
<ali1234> but if you adjust cube() so that it writes to stdout instead of returning geometry, then it writes to stdout no matter where you call it
<stealth_> you can store like a tree structure on start of the file.
<ali1234> then what?
<ali1234> where do you add things to the tree?
<stealth_> like `if not holder: holder = []`, inside each function have it upload render to `holder.append(["data", parent=?])`
<ali1234> yeah but what is parent?
<stealth_> another way you can have `cube()` above that have `@holder()` this will get initialize at runtime.
<stealth_> `@holder()def cube(...): ...`
<stealth_> its how flask and other framework cache url paths at runtime.
<ali1234> yes but you still haven't said how you are going to obtain the values you want to store
<stealth_> you can store is in tree list?
<stealth_> ali1234, https://github.com/SolidCode/SolidPython see they do that `d = cube(5) + right(5)(sphere(5)) - cylinder(r=2, h=6)` operator
<ali1234> okay well i can't get pythonscad to work, either the appimage or building it myself. it just says "error: python not found. is it installed?"
<stealth_> ali1234, i haven't used that so dono could ask more in #python i did try https://pypi.org/project/solidpython2/ and it seem to install fine.
<ali1234> self-build behaves different. it doesn't recognize python files at all. it won't even let me open them, and if i type one out manually it just produces a syntax error because it wants openscad
<stealth_> sorry, i have no clue about that library and its working.
guso78k has quit [Quit: Client closed]
<ali1234> got it working. i must have been missing some library - but not one that makes the build fail
J25k70 has quit [Quit: Client closed]
J25k70 has joined #openscad
badcad has joined #openscad
J25k70 has quit [Quit: Client closed]
J25k70 has joined #openscad
J25k40 has joined #openscad
J25k70 has quit [Ping timeout: 240 seconds]
<ali1234> okay i have a LOT of feedback about how this works
badcad has quit [Quit: Client closed]
lastrodamo has joined #openscad
drfff has quit [Ping timeout: 252 seconds]
drfff has joined #openscad
hyperair has quit [Ping timeout: 260 seconds]
_whitelogger has joined #openscad
mmu_man has quit [Ping timeout: 260 seconds]
Guest69 has joined #openscad
L29Ah has quit [Ping timeout: 248 seconds]
<Guest69> hi all, I posted a similar question on /r/openscad as well. Is there a way to 'jump' to particular faces on a object? for e.g. if I have a cube, I want to to be able to specify a named faced to add another object to, is there such a capability?
hyperair has joined #openscad
hyperair has quit [Ping timeout: 252 seconds]
Guest2 has joined #openscad
hyperair has joined #openscad
guso78k has joined #openscad
<guso78k> ali1234, https://bpa.st/SA6A, our past is also nice, build123d follow such an approach
<guso78k> in pythonscad  its something like: MyShape(10,2,Sphere(5)+[123]).color("red")
<guso78k> but can also add the with: syntax
<guso78k> pythonscad suports oprators for boolean ops, like solidpython does, but its not a layout on top of openscad, its native instead
Guest64 has joined #openscad
Guest64 has quit [Client Quit]
Guest2 has quit [Quit: Client closed]
guso78k has quit [Quit: Client closed]
stealth_ has quit [Quit: Leaving]
guso78k has joined #openscad
hyperair has quit [Read error: Connection reset by peer]
<guso78k> ali1234, please share your feedback with me. the message "Python not found, is it installed" means, that python cannot find its std library at startup.  you can best provide that by  having python installed in the system
<ali1234> obviously i do have python installed, but it is python 3.12, and the appimage is looking for 3.11 (not 3.12 as the webpage claims)
hyperair has joined #openscad
<ali1234> also you have a typo on the webpage irc link. it says "#pyopencad" instead of "#pyopenscad"
<ali1234> openscad.cube((1,2,3)).show() doesn't work - functions should accept any sequence of appropriate length
<ali1234> i could not figure out how to make this work: https://bpa.st/OJAQ
<ali1234> there is another typo in the tutorial section of the website. it refers to "os_import" but this function is called "osimport"
<ali1234> i dont understand how osinclude() or osuse() are supposed to be used
<ali1234> and i don't understand what output() even does
<ali1234> if the module is run headless, how do we export geometry?
<ali1234> is output just a synonym for show?
<ali1234> if you call show multiple times, only the last one does anything
Reisga2449 has joined #openscad
misterfish has joined #openscad
<guso78k> thank you for the feedback, will resolve all of them
<guso78k> outrput == show, yes
<guso78k> on headless build , you can get the geomtryw ith:
<guso78k> export(solid, "filename.extension") e.g.
<guso78k> exporting with 3mf even supports exporting multiple individual shapes by using a dict of solids instead of a solid
<ali1234> cool. so you can export different things to two separate files from within the same script... even from within a loop. that's huge
<ali1234> i'm not sure how show() should work
<ali1234> but having only the last one do anything doesn't seem ideal
<ali1234> okay build123d looks interesting. but how does it work?
<ali1234> Guest69: not easily possible in basic openscad but i think some libraries like bosl2 add such features, or the python wrappers also support it i think
<ali1234> ah build123d is doing inspect magic, like i said :)
<ali1234> still, interesting that someone actually already did it
<ali1234> apparently quite successfully too since that repo is still updating
<guso78k> only last show() in the script will have an effect. you can  can type: a=cube([1,2,3]) and then a.show(), then press F5 or F6
<guso78k> build123d is brother of cadquery. but pythonscad can also display with small tricks
<ali1234> i noticed manifold itself has a python wrapper too
<guso78k> build123 suports with: python statement, and apparently implement enter and exit methods
<ali1234> yes, that's why it is so interesting. i much prefer that syntax
<guso78k> need to catch up now and correct your findings :)
<ali1234> i dont like method chaining very much
<ali1234> it just makes super long lines
<guso78k> i think  the with: behaviour can be implemented in python language only
<ali1234> what do you mean?
<ali1234> like patching python interpreter?
<ali1234> build123d does it by inspecting the stack to find the context so it doesn't need patched interpreter
<ali1234> it is a bit hacky though
<ali1234> it doesn't behave like "normal" python code, which can be surprising. that's the downside to it
<guso78k> i was refering to this info i found: https://www.geeksforgeeks.org/with-statement-in-python/
<guso78k> sorry its in german, i am sure similar exists in english\
<ali1234> it's not in german for me. that is just a basic summary of how with: works in python though
<guso78k> no, it defines the methods __enter__ and __exit__ which will enable with: use
<ali1234> yes, that's what with blocks do: they call __enter__ at the start and __exit__ at the end, or on catching an exception
<ali1234> but those methods normally cannot access any of the code inside the with block, because it isn't a scope
<ali1234> so build123d has to inspect the interpreter stack frames to implement its context managers
<guso78k> ahh, but beyond my knowledge
<ali1234> this fundamentally changes the behavior of with blocks when the context manager is a build123d builder object
<ali1234> and it is only possible because python programs can stop and "debug" themselves at any time
<gbruno> [github] scrameta synchronize pull request #5584 (RFC: New general-purpose extrusion mechanism - 2025 refresh) https://github.com/openscad/openscad/pull/5584
<guso78k>  a1234, if you can come up with an usable way to integrate with: with pythonscad, i am happy to merge .
<ali1234> i'll keep thinking about it. maybe there is a nicer way to get the syntax benefits without the behind-the-scenes hackery
guerd has joined #openscad
mmu_man has joined #openscad
bunnyhamer has joined #openscad
L29Ah has joined #openscad
bunnyhamer has quit [Quit: Client closed]
teepee_ has joined #openscad
<guso78k> ali1234:  scad() function has only one string argument and the embedded scad code MUST return geometry to work. no submodule calling is supported. simplest example is :
<guso78k> scad("cube([1,2,3]);") but also more sophisticated scad is possible as long as it directly returns geometry
<guso78k> what you probably want is osinclude - matches to openscad include or osuse which matches to to openscad use
<guso78k> you can try:
<guso78k> lib = osuse("scadfile")
<guso78k> then : lib.my_scad_module(1,2).show() e.g.
teepee has quit [Ping timeout: 264 seconds]
teepee_ is now known as teepee
<guso78k> but osuse is known  to have some memory issues and does not yet work reliable
guso78k has quit [Quit: Client closed]
guso78k has joined #openscad
<JakeSays> the single biggest issue with python based scad tools is... python.
<guso78k> its an issue and a chance at the same time
<JakeSays> a chance for what?
<guso78k> python brings many intersting language features which openscad is lacking or need to go complicated detours. and it comes with a great pip library. but after all:  its a matter of taste
<JakeSays> the language itself is not worth using it.
<guso78k> i prefer to use tabs instead of backets and quotes  - this is my taste
<JakeSays> and those with blocks..
<JakeSays> guso78k: quotes?
<guso78k> sorry, i meant paranthesis ;)
<JakeSays> i see lots of parens in those build123d examples
<guso78k> link ?
<JakeSays> er,
<JakeSays> not that
<JakeSays> but any example will do
<guso78k> this a set of many small example invocations and comparable with openscad. but as soon as functions/modules are involved, openscad uses {()} where as python uses tab indents  and this needs less quotes, braces
<JakeSays> yes, and more tabs
<JakeSays> i much prefer braces
<JakeSays> and you also have those silly with constructs
<teepee> 'with' is good
<gbruno> [github] t-paul closed pull request #5690 (Python in OpenSCAD - yet another attempt) https://github.com/openscad/openscad/pull/5690
<JakeSays> teepee: for what?
<gbruno> [github] t-paul pushed 5 additions 4 modifications 1 removals (Python in OpenSCAD (#5690) Add first python module (`cube()`). Switch hash library from crypto++ to nettle. --------- Co-authored-by: Guenther Sohler <guenther.sohler@photeon.com> Co-authored-by: Torsten Paul <Torsten.Paul@gmx.de>) https://github.com/openscad/openscad/commit/69998f854a22524558639d864780c0446624131b
<teepee> I'm not a huge fan of python, including the tab/spacing thing
<guso78k> some guys love python and some do hate it. it appears, that there is nothing in between O:3
J25k40 has quit [Quit: Client closed]
<JakeSays> there isn't
J25k40 has joined #openscad
<teepee> but it has the benefit of being widely used, having impressive support and documentation
<teepee> with conrolling resources in a 100% safe way is a good solution
<teepee> C++ does that well with RAII
<JakeSays> teepee: well, it's good in the sense that python w/o it would be a leaky mess, but it's not good that its needed at all
<teepee> in java it's a bit annoying but mostly solved with expressions in try()
<JakeSays> i'm speaking specifically about using it as a scad
<teepee> huh? in any language using *actual* resources, there is NO way around some sort of solution
misterfish has quit [Ping timeout: 252 seconds]
<teepee> in scad essentially being "just" an evaluation it might be difficult to find an actual use case
<teepee> anyway, if we solve one language, adding more is probably not too hard
<teepee> specifically sandboxed ones
<JakeSays> teepee: no, my point is that when you adapt a language (python) to function as a hacked up dsl (scad'ish), you need to expose things like lifetime management to the developer
<teepee> I don't see it as DSL, we have that
<teepee> adding python enables use cases a strict dsl makes difficult
<JakeSays> with openscad i can focus on my design, not on dealing with things out of scope
<teepee> yes, and therefore I like it and it's not going to be replaced
<JakeSays> teepee: wait, you're not adding python to openscad, are you?
<teepee> but we will not add database access to scad
<teepee> the first patch for that is included for a year
<JakeSays> for what?
<JakeSays> i mean, what's it used for?
<teepee> "it" refers to what exactly?
<JakeSays> python
<teepee> optional (when enabled at compile time) 2nd langue that can be edited and run directly in the openscad application generating meshes for export
<JakeSays> how does it relate to scad?
<JakeSays> scad the language
<teepee> pretty much not at all
<JakeSays> does it have access to openscad internals?
<teepee> yes, that's the point of integration
<teepee> e.g. all the render stuff exists once independent of how the design was created
<JakeSays> do you have a link to an example? i'm not getting how it's used
<teepee> most simple case
<JakeSays> ahhh okay so it is literally a replacement for scad. i get it now.
<teepee> full state, currently separate https://pythonscad.org/