<Virindi>
heya, I made a bunch of changes to a big project which worked before, and now when I try to open it in openscad it just hangs forever taking 100% cpu. any ideas what I might have done wrong?
<Virindi>
Oh. I left it for 5 minutes. Now it is showing a million errors. Oops :)
<Virindi>
I guess if you make a mistake and cause millions of errors, each error being shown must be rather slow
<JordanBrown1>
I think there was a regression a while back that means that errors and echo output are not displayed as they happen, that they are only displayed when the program completes.
<Virindi>
hmm, that makes sense. I wasn't sure if it was actually doing anything
<Virindi>
it seems that each error takes an extremely long amount of time or something also, the net result is that debugging what I did wrong is very difficult because everytime I make a change I have to wait 5 minutes to even get the UI to respond again
<kintel>
Virindi Depends on the error/warning, you can tune some of that in Preferences->Advanced
<kintel>
Also, you could try to enable Manifold under Preferences->Features
<kintel>
-> that should cut down your rendering time with a couple of orders of magnitude
<Virindi>
you missed what I said earlier, I made some mistake changing a huge project and it generates a very large number of errors, but the result of that now is that when I preview the UI freezes at 100% cpu for 5 minutes before it even starts drawing the geometry
<Virindi>
no progressbar until it is done
<Virindi>
just frozen UI
<kintel>
what if you render instead of preview? Same issue?
<Virindi>
no.
<Virindi>
render works.
<Virindi>
it seems to be at the reload step
<kintel>
If what you have is shareable, it could be worth uploading it somewhere, in case you found a new bug
<Virindi>
also I tried manifold last year but I had to turn it off because it kept giving me corrupt geometry :)
<Virindi>
it's...not shareable
<kintel>
Manifold was greatly improved last month
<kintel>
..but get the absolutely latest snapshot. Things change weekly as we iron out the more tricky bugs
<Virindi>
yeah I am using the latest nightly debian package
teepee_ has joined #openscad
<Virindi>
I noticed something about python appeared in the file menu. Holy cow. Did one of the many alternate language things actually get merged?!
<kintel>
It's heavy WIP, not yet part of the build
<kintel>
..but guso78 is maintaining an alternative build with unmerged features
<Virindi>
hrm. I restarted openscad to run it in console to see if I got anything, and now it is not doing it anymore
<Virindi>
it shows the progressbar immediately when starting the preview
<Virindi>
maybe it has something to do with caching then? I use render() a lot.
LordOfBikes has quit [Ping timeout: 255 seconds]
<Virindi>
the source of my warnings is bizarre. I have something like
<Virindi>
foo = (x=="abc");
<Virindi>
bar = !foo? a : b; // <--------- warning: unknown variable foo
<Virindi>
it is literally on the next line
<Virindi>
two lines further down, it uses foo again, but that one doesn't show a warning
erectus has quit [Ping timeout: 260 seconds]
erectus has joined #openscad
<kintel>
Virindi This sort of stuff usually happens if you attempt to re-assign a variable
<kintel>
There should be a warning, but what happens is that any re-assignment gets moved to the first assignment of said variable.
<kintel>
If you have dependent variables, things go south really quickly
<Virindi>
ahhh, you're right. bar was already defined.
<kintel>
that warning should be a hard error, but due to backwards compatibility we haven't enforced it
<JordanBrown1>
Sure would be nice to do something about that. But I understand the "include" problem.
<Virindi>
but bar only depends on foo in this file, in the other file it doesn't. so the warning is nonsensical
<kintel>
If you include files, everything goes into the same scope.
<Virindi>
the warning text is telling me something that is actually wrong. shouldn't it at least not do that
LordOfBikes has joined #openscad
<kintel>
If the warning says you reassign, it's likely a correct warning :) Hard to say without an example
<Virindi>
no.
<JordanBrown1>
kintel yes, I know; the problem is (as you know) that it's desirable to be able to set a variable in an included file and override it in the main file.
<JordanBrown1>
but since include is done at such a crazy low level it's probably impossible to detect that particular case and special-case it.
<Virindi>
file 1:
<Virindi>
foo = (x=="abc");
<Virindi>
bar = !foo? a : b; // <--------- warning: unknown variable foo
<Virindi>
file 2:
<Virindi>
bar = z;
<kintel>
I've been wanting to move include to a separate scope for ages, but hard to pull off..
<Virindi>
and the warning is WARNING: Ignoring unknown variable 'foo' in file file1.scad
<kintel>
Virindi what's the interaction between the files?
<Virindi>
file2 is included first, then file1 is included.
<Virindi>
I understand that what I did is incorrect, but the warning is wildly misleading
<JordanBrown1>
So you mean that file0 has "include <file1.scad>" and "include <file2.scad>"?
<Virindi>
other way around.
<Virindi>
file0 includes file2, then file1
<JordanBrown1>
ah, right.
<JordanBrown1>
Yeah, so the weirdness is that the file1 definition of "bar" gets teleported to the location of the original definition of "bar" in file2... and at that point "foo" isn't yet defined.
<Virindi>
I mean. Based on that warning text how am I supposed to figure out what I did wrong, it is pointing me in the wrong direction :)
<InPhase>
Virindi: undef and nan propagation is almost always the source of those huge explosions in preview time after an error.
<JordanBrown1>
I agree. But it's what happens, and it can't be simply changed because there are cases where this behavior is useful.
<Virindi>
I think it would certainly be sufficient to just have a WARNING: redefinition of bar
<InPhase>
Virindi: There's clearly something that should be optimized there.
<Virindi>
if that warning appears first that is :)
<JordanBrown1>
The idea behind that teleportation is that an included file can say "a = 1; b = a + 1;", and then the main file (or a second included file) can say "a=2;", and the result is that b=3.
<InPhase>
Virindi: I will add that I find editing the code outside of the built-in editor makes this problem far less painful... You can edit externally without waiting for the preview, and simply save, kill openscad, and start it again to see if you fixed it.
<Virindi>
InPhase: I never use the builtin editor. I use geany :)
<JordanBrown1>
Maybe I am the only one :-)
<InPhase>
Virindi: Also, commenting out the bottom half of the file or something can be very helpful sometimes. Then you can start echo'in values as you add things in, and hunt for the bad parts.
<InPhase>
echo'ing
<Virindi>
I think the 5-minute hang has to do somehow with caching because restarting the program caused it to go away?
<Virindi>
it hasn't come back yet.
<InPhase>
I don't think I've ever seen a huge runtime from caching. Maybe you fixed it by accident?
<Virindi>
the only change I made was a bogus one just to alter the file.
<InPhase>
Or like, saved in your editor, and you previously forgot to save/
<Virindi>
it is definitely the same files
<Virindi>
as was hanging
<InPhase>
Gremlins?
<Virindi>
or, it was until I continued debugging :)
<Virindi>
you know, going through a million files and renaming bar ;)
<Virindi>
it would even be nice to be able to specify variables as only existing in the current file
<Virindi>
accidental 'bleed' of similar variable names between different files is a huge problem and basically means every variable has to be named like, filename_variablename
<JordanBrown1>
"use" helps with that, but has its own issues.
<Virindi>
even worse because there is no way to know if you accidentally used the same name other than things being broken
<Virindi>
yeah, I use 'use' sometimes but it would be nice to have some variables local, others global
<Virindi>
in the same file
<Virindi>
'use' requires that you maintain some kind of scope hierarchy with how you include/use files and that is diffult
<Virindi>
difficult*
J24k86 has joined #openscad
<JordanBrown1>
If such a thing ever happens, I expect that it would only be in the context of a "use"-style mechanism. The definition for "include" is that it is as if the text of the file was included at that point, and that's a pretty inflexible definition as far as scoping goes.
<Virindi>
if in file0.scad I wrote:
<Virindi>
local foo = 1;
<Virindi>
it could just silently rename foo to file0_foo
<Virindi>
that would make things so much cleaner
<JordanBrown1>
assume that main says "include <file1>", "include <file2>", et cetera.
<JordanBrown1>
file 1 could say "foo"
<JordanBrown1>
file 2 could say "="
<JordanBrown1>
file 3 could say "1"
<JordanBrown1>
file 4 could say ";"
<Virindi>
hah
<Virindi>
wow. I hope nobody actually splits statements between included files!
J24k has quit [Ping timeout: 250 seconds]
<JordanBrown1>
That's obviously a contrived example, but something like
<JordanBrown1>
var = [
<JordanBrown1>
include <data.scad>
<JordanBrown1>
];
<JordanBrown1>
isn't totally silly.
<Virindi>
well.
<Virindi>
the interpreter, when it gets to 'foo', can just look at whether it has seen a 'local'. if so, it uses the filename that it is currently in. even if 'local' and '=' are in different files
<Virindi>
so if you have
<Virindi>
file1: local
<Virindi>
file0: include "file1.scad" include "file2.scad" include "file3.scad" include "file4.scad"
<Virindi>
file2: foo
<Virindi>
file3: =
<Virindi>
file4: 3;
<Virindi>
then foo becomes file2_foo
<JordanBrown1>
the inclusion is done at the lexer, before the parser sees it.
<JordanBrown1>
it's actually more powerful (more insane) than that.
<Virindi>
sheesh
<JordanBrown1>
v = [ include <2.scad> ];
<JordanBrown1>
works.
<Virindi>
well it has to know what file it is in, because warnings specify what file they are in :)
<JordanBrown1>
And if you think that it always gets those right in these extreme cases...
<Virindi>
I figured that every token just had a file and line number attached to it or something
<JordanBrown1>
I don't know for sure.
<JordanBrown1>
But indeed for the cases I just tried, it did better than I expected.
<JordanBrown1>
Anyhow, trying to do such a thing would bug me because it would violate the "as if the text was inserted at that point" definition.
<JordanBrown1>
I'd be much happier with something like having "use" have a mechanism where you could say
<JordanBrown1>
export myvar = 57;
<JordanBrown1>
My favorite idea is to tie into the object stuff in PR#4478 and have a "use" function, so you would say something like
<JordanBrown1>
foolib = use("foolib.scad");
<JordanBrown1>
and then say
<JordanBrown1>
foolib.foomod();
<JordanBrown1>
x = foolib.foofunct();
<JordanBrown1>
and so on.
<Virindi>
that would be nice indeed
<JordanBrown1>
Yeah, it almost completely fixes the namespace problem. It isolates it to the file path.
<Virindi>
I mean, right now I have about 50 files in one project and I can never keep track of which thing is from what unless I just name every function, module and variable after the name of the file.
<Virindi>
it is tedious and prone to error
<JordanBrown1>
One might wonder why you have 50 files, if there isn't a clear definition for what belongs in each file that would tell you where it is.
<Virindi>
of course there is
<JordanBrown1>
I mean, sure, there's gray. But usually not *that* much gray.
<Virindi>
but there are lots of things which are shared concepts between multiple modules
<Virindi>
right now I define "interfaces" but it is really just a bunch of specially named variables
<Virindi>
it is very C
<JordanBrown1>
Yep. Which is where, I'm sure, the definition of "include" came from.
<Virindi>
dunno. I know OO is super overused, I get that, but not having any of it at all is also painful
<JordanBrown1>
Yes.
<JordanBrown1>
Even without the "use" function, you can do some clever things with PR#4478.
<JordanBrown1>
You can have file1.scad define a single variable "file1" that is an object containing all of the stuff that file1 wants to export.
<Virindi>
I use a lot of what I call the 'nophead pattern', defining vector 'objects'
<Virindi>
but.
<JordanBrown1>
You can fake a lot of it with vectors, but #4478 does it more directly.
<Virindi>
vector objects work great for something like, defining the dimensions of a generic type of fan for example. it is not so great when the thing you are defining depends on other things.
<JordanBrown1>
You'd need to use let() to define a host of temporary variables that you then transcribe into the final vector.
<Virindi>
and what if multiple modules need to cooperate to find one of the values? :)
<Virindi>
for example
<Virindi>
I have a circuit board in a mount module, and next to it maybe I have a fan in a fanmount
<Virindi>
the locations of them might be a min() of parameters between each side
<Virindi>
perhaps it depends on both the size of the circuit board and the size of the fan
<JordanBrown1>
sounds like your circuitboard.scad needs to export the circuitboard module and some parameters, and fan.scad needs to export the fan module and some parameters, and the main file needs to consult the parameters from both to decide where to position each.
<Virindi>
in other words, the fact that you must define the entire vector at once means that the dependency order for *every vector element must be identical*
<Virindi>
yes.
<Virindi>
however.
<Virindi>
the main module cannot then assign further parameters for the circuit board based on that calculation.
<JordanBrown1>
It sounds like you are saying that the position of the fan is a parameter of the fan. Normally it shouldn't be.
<Virindi>
I mean it can, but they can't go in the vector :)
<Virindi>
it was just a contrived example.
<Virindi>
in reality it is more like, part A and part B, and the shape of part A changes based on its geometric relation to part B
<Virindi>
and things like that
<JordanBrown1>
I'm not saying that there aren't such problems, but that if you are pretty obsessive about modularity and information hiding and structure the assemblies correctly, I suspect that most of the problems go away.
<Virindi>
we've been working on this particular project for like 10 years, there has been plenty of obsessing :)
<Virindi>
let's say, part A has a screw in position X if and only if part B falls to the left of part A
<Virindi>
for example
<Virindi>
it is a level of modularity that is perhaps unreasonable
<JordanBrown1>
Sounds like parts A and B are not really independent parts.
<Virindi>
nothing in the entire assembly is actually independent :)
<JordanBrown1>
Or that part A has two variations, one with and one without the hole, and its caller (which knows where it is placing both A and B) tells it which variation to use.
<JordanBrown1>
s/use/create/
<Virindi>
yeah but if we used that paradigm, the permutations would get out of control fast.
<Virindi>
dunno, I am not complaining, I am just not sure if there is a better way than what we are doing right now
<Virindi>
basically in that example, figuring out if B is to the left of A requires a huge pile of calculations about the shape of A which really fit inside A
<JordanBrown1>
I am hopeful that we can get some motion on #4478 and provide more options for modularity and namespace management. I don't know that it will help with your dependency issues, though.
<Virindi>
I had really been hoping that if someday some extra language (such as python) were merged, there would be some framework for backward compatibility so both languages could talk back and forth. not sure if that is the case with pythonscad
erectus has quit [Remote host closed the connection]
<Virindi>
any language that operates sequentially would help solve the problem :P
<JordanBrown1>
I think he's done some work on that.
erectus has joined #openscad
<JordanBrown1>
But I am paranoid about the security implications. It's currently "safe" to download and run a .scad file from Thingiverse without inspecting it. Python-based systems can't make that kind of guarantee.
<JordanBrown1>
(Or maybe they can, but end up so lobotomized that you lose half the reason you wanted to run Python.)
<Virindi>
yeah I get that. I am probably pretty unique in that 99.9% of what I use, I write only myself...well, me and my partner
<JordanBrown1>
For some environments, it's perfectly OK. I mean, there's a lot of open-source Python and C out there, and it all has this risk.
<JordanBrown1>
But if you download some random C file or Python file from some random web site, and run it, you're just asking for trouble.
<Virindi>
there are a lot fewer eyes on some random printables file than on a typical open source git project
<JordanBrown1>
Exactly.
<JordanBrown1>
And, as the xz debacle demonstrates, even projects that might have a bunch of eyes on them can have malicious leaks.
<Virindi>
even with xz there was another line of defense for many: the stable-unstable-testing paradigm slowing down updates from upstream
<Virindi>
to me it seems like a lesson that you shouldn't update so fast :)
<JordanBrown1>
Yep. But we still escaped a disaster by a narrow margin.
<JordanBrown1>
Now, to be fair, OpenSCAD users are also a lot less attractive a target than SSH users.
<Virindi>
the other day I was fighting to get some bloatware to compile and it struck me how their system has piles of hex-encoded super long constants in the makefile. kinda like xz. people need to really not do that
<Virindi>
wait, hold on. are you telling me the US government doesn't use openscad for war planning?
<Virindi>
mind blown
<Virindi>
you wouldn't pay if someone held all your .scad files ransom for 10000000 BTC?
<Virindi>
I have often wondered though about sites that integrate openscad. Perhaps printables or thingiverse style sites. Surely there is some way to write a .scad file to gain code execution :)
hyperair has quit [Remote host closed the connection]
hyperair has joined #openscad
qeed has joined #openscad
kintel has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rawgreaze has quit [Ping timeout: 240 seconds]
erectus has quit [Ping timeout: 260 seconds]
rawgreaze has joined #openscad
GNUmoon2 has quit [Ping timeout: 260 seconds]
J24k32 has joined #openscad
<J24k32>
Kintel would it be possible to chatch polyhedron error on first occurrences. E.g. not everything is catchend by assert() or corrected in my scripts and then it freezes for several minutes only to show that my "thousand" points are out of range or couldn't compute or mismatch .. So it would be great if the calculation stopped at the first
<J24k32>
and not try to calculate the rest - which is also taking much longer than calculating the polyhedron without error.
J24k86 has quit [Ping timeout: 250 seconds]
GNUmoon2 has joined #openscad
teepee_ has joined #openscad
teepee has quit [Ping timeout: 260 seconds]
teepee_ is now known as teepee
guso78k has joined #openscad
erectus has joined #openscad
erectus has quit [Remote host closed the connection]
erectus has joined #openscad
erectus has quit [Ping timeout: 260 seconds]
guerd87 has quit [Ping timeout: 256 seconds]
guerd87 has joined #openscad
cart_ has joined #openscad
ali1234 has quit [Remote host closed the connection]
ali1234 has joined #openscad
guso78k has quit [Ping timeout: 250 seconds]
mmu_man has joined #openscad
teepee has quit [Remote host closed the connection]
teepee has joined #openscad
Lagopus` has joined #openscad
Lagopus has quit [Ping timeout: 255 seconds]
GNUmoon2 has quit [Remote host closed the connection]