<Guest68>
Hi folks, I have 2 two questions re: openscad...
* InPhase
inserts space for the questions: ______________________
<Guest68>
Q1: I know I can import (stuff) in a program but I'd also like to export programmatically. I have a program that makes 70 or so shapes, I'd like to render and then export these as .stl in turn from openscad without using the UI - I can't find any documentation about this - is it possible?
<InPhase>
Yes, you do it from the command line, and pass in variables with the -D command line argument to set variables which determine which shape to display.
<InPhase>
Do "openscad --help" to see all the arguments. A typical workflow involves making a small bash script or something to call OpenSCAD repeatedly for a set of things you want to make.
<InPhase>
Bash is the simplest approach on all the decent platforms. For Windows you can suffer through one of the built-in Windows scripting languages, install bash and use that, or attempt to call it repeatedly with something like Python which gives you far more flexibility.
<Guest68>
Q2: I think I know how for works in openscad as an array generator. In my case I want to automatically layout my shapes inside a for (or other) loop. I want to space the shapes automatically so they don't intersect. My shape generating modules can be called from functions which return their footprint sizes which can then be used to iterate
<Guest68>
the spacing: something like dx=0; for(i=...){dx=dx+shapesize(i);translate([dx,0,0])makeshape(i);} but I don't think this will work with openscad, any suggestions?
<Guest68>
Ok A1: I can't programme it from inside openscad but I could script it from outside via the CLI and -D option. The scripting is not a problem for me but it's a shame openscad is missing this property because it makes sharing the openscad program more difficult. - thanks for the answer!
<Guest68>
Q2: I think I've worked this out (it's a slow brain day here): I use shapesize to generate a list of all the dxs I want, then transform that to give the xs I want then for(i=list)translate([i,0,0])makeshape(i); - just need to work out how to sum the list of dxs to get the xs.
<InPhase>
Guest68: And here's an example of how I like to do model selection by variable: https://bpa.st/QVZQ
<InPhase>
As for spacing shapes by known sizes, there are two ways. One is the recursive strategy, the other is the list summing strategy.
<Guest68>
Thanks for the example, quick question, can -D be used to easily pass a list eg -D [1,4,5]?
<InPhase>
Yes, but you might need to put quotes around some things like that, depending on how you're calling it.
<InPhase>
Guest68: Here is an illustration of the recursive spacing strategy. In this case, it's showing the most elaborate case of spacing from a chain of objects of various lengths and orientations: https://bpa.st/H2KQ
<Guest68>
Thanks! your help is much appreciated!
<InPhase>
The general strategy goes exactly like that, but is sometimes much simpler. The key is simply that i=0, incrementing it, translating the recursive calls, and setting up that base-case to stop recursing if i is greater then the length (or some other variable passed in).
<InPhase>
If you do View, Animate, and put in the values in the comments, you will amuse yourself and also see how flexible the recursive approach is.
<InPhase>
https://bpa.st/H3IA This is an example of the integral strategy for determining spacings.
<InPhase>
(It has many other convenience functions like that in the other files.)
<J1A84>
Guest68 you can use a module and recursively call that module to relatively position your object to the one before
<InPhase>
Guest68: Sometimes for the integral approach you might want to add a padding between as well. It is easy enough to add that in, you just have to add a parameter, carry it through, and add it at each step to the accumulating sum like this: https://bpa.st/5OAA
<InPhase>
For the recursive approach you would just add that pad to the translate for each recursion.
tcurdt has joined #openscad
poisond has joined #openscad
<poisond>
hi :) is there a way to add a chamfer to text without involving minkowski() ?
<poisond>
(don't want to wait 30m for a render ...)
<InPhase>
poisond: There's roof in experimental.
<InPhase>
color("orange") roof() { text("The roof, the roof,"); translate([4, -12]) text("the roof is on fire"); }
<poisond>
hmm .. compiled with -DEXPERIMENTAL=ON -> "WARNING: Experimental builtin module 'roof' is not enabled..."
<InPhase>
You have to turn it on in preferences.
<InPhase>
Under Features.
<poisond>
aaahhh, thanks InPhase !
<InPhase>
You can use some intersections and stuff to turn basic roof into a chamfer instead of a full roof.
<InPhase>
Scaling is also an option to alter the angles involved.
<InPhase>
There is some stalled work on a more flexible offset_extrude to do all of this in one go, but it hit some hurdles and stalled out.
<poisond>
roof() works out perfectly for my use case, thanks :)
<poisond>
is there some doc beside the source for it?
TheAssassin has quit [Remote host closed the connection]
TheAssassin has joined #openscad
<J1A84>
i made this in my lib . .but it is just a scale with tan()
<J1A84>
there is a roof example within the examples with a little docu
<J1A84>
basics ⇒ roof.scad
<InPhase>
poisond: It was raised as a thought, but that's deferred for the offset_extrude for which it might be really nice if it went full-flexible and took function literals for the offset shape.
<InPhase>
poisond: Until then, scale is good enough to provide that angle adjustment.
<poisond>
fair enough
<InPhase>
poisond: Having a functional form on offset_extrude could replace most of the minkowski needs.
<InPhase>
We could trivially chamfer and fillet in all sorts of ways then.
<InPhase>
It would cover at least everything that has a flat base.
<poisond>
yeah. I meant creating a chamfer/fillet usually is easy enough, except for text/polygons/scg ... I'm looking forward to it
<InPhase>
J1A84: Nice. What syntax does that look like?
<J1A84>
polyRund(points,ofs=0,delta=0)
<J1A84>
(also r and ir for rounding without offset is possible .. delta and ofs can be combined .. and r can be list to round each point with different radii )
<InPhase>
J1A84: I hope you're putting good attention to documentation. :) You're writing many treasure troves of things that are non-obvious how to do.
<InPhase>
or perhaps also, non-obvious how to use. Both I suppose.
<J1A84>
i am adding doxy gen comments on each (new) with examples
<InPhase>
Yeah, that should help.
<InPhase>
Have you reached the point where include<ub.scad> has a noticeable lag? :)
<InPhase>
I see you are over 10,000 lines.
ur5us has quit [Ping timeout: 248 seconds]
Guest68 has quit [Ping timeout: 252 seconds]
<J1A84>
it is between 100 and <300ms like all libs
<J1A84>
more annoying is that i have {} for folding but doxygen will not work with them
<J1A84>
the most delay is due to the echo (which can now be turned off completely)