Actually I decided to just code a check for Booleans and it seems to not barf with inValid Shape but does not produce the same results as the op gets But when I try the code in OpenSCAD I get the samekeithsloan52 wrote: ↑Wed Feb 02, 2022 3:10 pmI think the problem with this one is the code is probably correctly creating the extrusion but the Shape needs a recomputebvwj wrote: ↑Tue Feb 01, 2022 9:50 pm Nested differences only got me so far.
Now this difference operation produces a very similar error. Just trying to hollow out a block.
test2.png
Code: Select all
$fn=64; difference() { linear_extrude(10) offset(r=2) square([40,30],center=true); // Case Outside translate([0,0,-1]) linear_extrude(6) offset(r=2) square([30,20],center=true); // Cutout }
Code: Select all
14:43:32 Traceback (most recent call last): File "<string>", line 1, in <module> File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 130, in open processcsg(tmpfile) File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 191, in processcsg result = parser.parse(f.read()) File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 1120, in parseopt_notrack p.callable(pslice) File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 649, in p_difference_action mycut.Shape = mycut.Base.Shape.cut(mycut.Tool.Shape) <class 'Part.OCCError'>: Tool shape is null
before it is valid see screen shot Image 02-02-2022 at 15.02.jpeg
2nd Opinion please
@chennes Chris please could you look at the one and I expect other functions/objects in OpenSCADFeatures
will have the same problem. As the problem shows up on Booleans maybe we need to change Boolean functions to Check the
objects being operated on have valid Shapes with ..Shape.isNull() and do a recompute if they are not, what do you think?
Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Yes, I have done a bit of that elsewhere, and I think it's really the only viable path forward. My general understanding is that basically anytime we create a Draft object we need to do a recompute, but also a lot of Draft manipulations, too. Best to be systematic about it and just always check.keithsloan52 wrote: ↑Wed Feb 02, 2022 3:10 pm change Boolean functions to Check the objects being operated on have valid Shapes with ..Shape.isNull() and do a recompute if they are not, what do you think?
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Have already done this and pushed updates to https://github.com/KeithSloan/OpenSCAD_Alt_Importchennes wrote: ↑Wed Feb 02, 2022 10:23 pmYes, I have done a bit of that elsewhere, and I think it's really the only viable path forward. My general understanding is that basically anytime we create a Draft object we need to do a recompute, but also a lot of Draft manipulations, too. Best to be systematic about it and just always check.keithsloan52 wrote: ↑Wed Feb 02, 2022 3:10 pm change Boolean functions to Check the objects being operated on have valid Shapes with ..Shape.isNull() and do a recompute if they are not, what do you think?
Are you okay with updating in the main branch importCSG.py with the new updates
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Yes, no problem, I can probably do it tonight or tomorrow.keithsloan52 wrote: ↑Thu Feb 03, 2022 8:27 pm Are you okay with updating in the main branch importCSG.py with the new updates
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
You are definitely on the right path. Capability is much better, but it still breaks down as complexity increases. Here I am just trying to cut out a shape for a connector. If the shape only has 1 or 2 elements, the cutout works, but if it is any more complex it fails.
Code: Select all
$fn=64;
module microD37() {
jackscrewDia = 3;
screwPitch = 32.26;
cornerRad = 2.64;
conWidth = 28.14;
conHeight = 6.5;
linear_extrude(10,convexity=10) {
union() {
translate([-screwPitch/2,0])
circle(d=jackscrewDia);
translate([screwPitch/2,0])
circle(d=jackscrewDia);
square([32.26,jackscrewDia],center=true);
offset(r=cornerRad)
square([conWidth-cornerRad*2,conHeight-cornerRad*2],center=true);
}
}
}
difference() {
cube([2,60,20],center=true);
translate([-5,0,0])
rotate([90,0,90])
microD37();
}
Code: Select all
11:00:03 19Standard_NullObject Traceback (most recent call last):
File "/Users/barry/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/OpenSCADFeatures.py", line 404, in execute
self.createGeometry(fp)
File "/Users/barry/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/OpenSCADFeatures.py", line 412, in createGeometry
if fp.Base and fp.Height and fp.Base.Shape.isValid():
<class 'Part.OCCError'>: 19Standard_NullObject
11:00:03 Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/barry/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/freecad/OpenSCAD_Alt_Import/importCSG.py", line 125, in insert
processcsg(tmpfile)
File "/Users/barry/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/freecad/OpenSCAD_Alt_Import/importCSG.py", line 157, in processcsg
result = parser.parse(f.read())
File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
p.callable(pslice)
File "/Users/barry/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/freecad/OpenSCAD_Alt_Import/importCSG.py", line 696, in p_difference_action
mycut.Shape = mycut.Base.Shape.cut(mycut.Tool.Shape)
<class 'Part.OCCError'>: Tool shape is null
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Are you sure you're using the latest fixes from @keithsloan52? I just merged his latest fixes into the main FreeCAD repo, and when I tested your code it looks the same as you show.
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
I just now did Tools->Update manager-> OpenSCAD_Alt_import -> Install/update. It said I had the latest version, but I restarted anyway to make sure.
I also copied the contents of the new importCSG.py and used them to replace my existing file.
Both methods still fail when run from FreeCAD.
What else can I try?
I also copied the contents of the new importCSG.py and used them to replace my existing file.
Both methods still fail when run from FreeCAD.
What else can I try?
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Everything is quite strange. The first time I import or open the file, I get no object displayed. There is a hierarchy of object in the Tree view. The twist_extrude object has an exclamation point icon.
1. If I import the file again, it shows up properly.
2. Also if I double click the twist_extrude then right click "finish editing" the part also shows up.
Any ideas?
1. If I import the file again, it shows up properly.
2. Also if I double click the twist_extrude then right click "finish editing" the part also shows up.
Any ideas?
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
This is the error trace when I import with importCSG.py.
14:00:00 WARNING: Token 'DOT' defined, but not used
14:00:00 WARNING: Token 'WORD' defined, but not used
14:00:00 WARNING: There are 2 unused tokens
14:00:00 Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 130, in open
processcsg(tmpfile)
File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 191, in processcsg
result = parser.parse(f.read())
File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/Applications/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
p.callable(pslice)
File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/importCSG.py", line 659, in p_difference_action
mycut.Shape = mycut.Base.Shape.cut(mycut.Tool.Shape)
<class 'Part.OCCError'>: Tool shape is null
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
That looks to me like an error you'd see prior to this morning's bug fix -- I don't remember what version of FreeCAD you are running, are you on a self-compiled version, or a daily, or what?