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!
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
@malorezzanzo00492 can you provide a test file and also your full About info? TIA
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Think offset only works on 2d shapes hence the test for Volume == 0 and barf, what 2d shapes are you performing a union on?malorezzanzo00492 wrote: ↑Sat Aug 13, 2022 9:48 pm There's a problem with linear_extrude()offset()union(){} and with linear_extrude()offset()union(){}.
In the second case FreeCAD gives this error:In the first case, instead, it seems to ignore the union() instruction.File "...", line ..., in p_offset_action
if subobj.Shape.Volume == 0 :
<class 'RuntimeError'>: shape is invalid
i.e Please supply a test file that gives a valid result with native OpenSCAD - Thanks
-
- Posts: 4
- Joined: Sat Aug 13, 2022 9:24 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
@keithsloan52 @Kunda1
This is an example of code falling into the second case:
In the attachment "unionOpenscad.png" the correct result with openscad, while in the attachment "unionFreecad.png" the wrong result with freecad.
This is an example of code falling into the first case:
In the attachment "differenceOpenscad.png" the result with openscad, while in freecad it gives the aforementioned error.
My About info:
This is an example of code falling into the second case:
Code: Select all
linear_extrude(200)offset(delta=-10)
union(){
square(100);
translate([100,0,0])square(100);
};
This is an example of code falling into the first case:
Code: Select all
linear_extrude(200)offset(delta=-10)
difference(){
square(100);
translate([50,0,0])square(100);
};
My About info:
Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: Italian/Italy (it_IT)
- Attachments
-
- differenceOpencad.png (2.54 KiB) Viewed 1282 times
-
- unionFreecad.png (3.14 KiB) Viewed 1282 times
-
- unionOpenscad.png (4.64 KiB) Viewed 1282 times
Last edited by malorezzanzo00492 on Wed Aug 17, 2022 7:14 pm, edited 1 time in total.
-
- Posts: 4
- Joined: Sat Aug 13, 2022 9:24 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Another problem, maybe correlated is this code with this particular polygon:
It gives this error:
Based on the polygon points, sometimes gives error and sometimes works.
My About info:
Code: Select all
linear_extrude(10)offset(delta=-2)polygon([[0,0],[0,230],[33,230],[33,260],[0,260],[0,500],[500,500],[300,-3],[243,-2],[243,-27],[125,-26],[123,-1]]);
Code: Select all
<Exception> makeOffset2D: result of offsetting is null!
Recompute failed! Please check report view.
My About info:
Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: Italian/Italy (it_IT)
Last edited by malorezzanzo00492 on Wed Aug 17, 2022 7:14 pm, edited 1 time in total.
-
- Posts: 4
- Joined: Sat Aug 13, 2022 9:24 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Other 2 problems:
The following code should render the "arcOpenscad" attachment, while it renders the "arcFreecad" one. The problems should be somewhere in the rotate.
This other piece of code should be a door frame as in the "doorOpenscad" attach, without the circular object at its feet:
My about info:
The following code should render the "arcOpenscad" attachment, while it renders the "arcFreecad" one. The problems should be somewhere in the rotate.
Code: Select all
arcElevation = 185;
arcRadius = 52;
arcWid = 10;
arcLen = 150;
rotate([0,90,0]){
// first arc
translate([0,0,-arcWid])union(){
linear_extrude(arcWid)square([arcLen,arcElevation]);
translate([arcLen/2,arcElevation,0])cylinder(h=arcWid,r=arcLen/2);
};
// second arc
translate([0,0,-100])union(){
linear_extrude(arcWid)square([arcLen,arcElevation]);
translate([(arcLen)/2,arcElevation,0])cylinder(h=arcWid,r=(arcLen)/2);
};
};
// central part
cube([arcLen,100,arcElevation]);
Code: Select all
//include <BOSL2/std.scad>
module doorframe (arcElevation,arcHeight,span,frameWidth,frameLength=2,subframeLength=7,height=210){
arcWidth = frameWidth-2;
arcRadiusInt = (span-6)/2;
arcRadiusExt = (span+3)/2;
arcScale = [1,(height-arcElevation)/(span/2),1];
arcPos = [0,arcElevation,-arcWidth/2];
framePos = [-(span+frameLength*2)/2,0,-frameWidth/2];
subframeWidth = frameWidth + 2;
subframePos = [-(span+frameLength*2+subframeLength*2)/2,0,-subframeWidth/2];
arcSorroundingPos = [0,arcElevation,-0.5];
rotate([90,0,0])union(){
//frame
translate(framePos)
difference(){
cube([span+frameLength*2,height+frameLength,frameWidth]);
translate([frameLength,0,0])cube([span,height,frameWidth]);
}
//subframe
translate(subframePos)
difference(){
cube([span+frameLength*2+subframeLength*2,height+frameLength+subframeLength,subframeWidth]);
translate([subframeLength,0,0])cube([span+frameLength*2,height+frameLength,subframeWidth]);
}
//arc
translate(arcPos){
scale(arcScale)
difference(){
// pie_slice(ang=180, l=arcWidth, r=arcRadiusExt);
cylinder(h=arcWidth, r=arcRadiusExt);
cylinder(h=arcWidth, r=arcRadiusInt);
translate([-arcRadiusExt,-arcRadiusExt,0])cube([arcRadiusExt*2,arcRadiusExt,arcWidth]);
}
}
//between arc and frame
translate(arcSorroundingPos)
difference(){
translate([-span/2,0,0])
cube([span,height-arcElevation,1]);
scale(arcScale)
cylinder(h=1,r=arcRadiusInt);
}
}
}
doorframe(arcElevation=174,arcHeight=36,span=71,frameWidth=12);
Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: Italian/Italy (it_IT)
- Attachments
-
- doorFreecad.png (4.75 KiB) Viewed 1244 times
-
- doorOpenscad.png (3.3 KiB) Viewed 1244 times
-
- arcFreescad.png (7.55 KiB) Viewed 1244 times
-
- arcOpenscad.png (3.79 KiB) Viewed 1244 times
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Thanks for reporting
@chennes I have created the following test files from details in the this thread
@chennes I have created the following test files from details in the this thread
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
I have added a fix to offset action to do a checkObjShape to check and perform recompute of the object if requiredkeithsloan52 wrote: ↑Wed Aug 17, 2022 9:36 pm Thanks for reporting
@chennes I have created the following test files from details in the this thread
Union_Squares.scad
Difference_Squares.scad
Offset_polygon.scad
Door_Arc.scad
ArcOpen.scad
to https://github.com/KeithSloan/OpenSCAD_Alt_Import this for me fixes difference.scad
Code: Select all
def p_offset_action(p):
'offset_action : offset LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE'
# print('Offset Action')
# print(len(p))
# print(f'p6 : {p[6]}')
if len(p[6]) == 0:
newobj = placeholder('group',[],'{}')
elif (len(p[6]) == 1 ): #single object
subobj = p[6][0]
else:
subobj = fuse(p[6],"Offset Union")
if 'r' in p[3] :
offset = float(p[3]['r'])
if 'delta' in p[3] :
offset = float(p[3]['delta'])
#print(subobj.Shape)
#print(dir(subobj.Shape))
#print(subobj.Shape.ShapeType)
checkObjShape(subobj)
With Offset_polygon the supplied offset is a negative number which causes errors
Code: Select all
23:25:33 <Exception> makeOffset2D: result of offsetting is null!
23:25:33 Recompute failed! Please check report view.
23:25:33 <Exception> makeOffset2D: result of offsetting is null!
23:25:33 Recompute failed : Offset2D
23:25:33 End processing CSG file
23:25:33 <Exception> makeOffset2D: result of offsetting is null!
23:25:33 Recompute failed! Please check report view.
@Kunda1
Still to debug problems with DoorArc and Union_Squares
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
Maybe open a new forum thread to discuss it?Should FreeCAD makeOffset2D be able to handle negative offsets? @Kunda1
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
(This has been reported in Debian: https://bugs.debian.org/cgi-bin/bugrepo ... bug=860789)
Quoting the Debian Bug:
Quoting the Debian Bug:
(Attaching a screenshot comparing FreeCAD 0.20.1 with OpenSCAD 2021.01, both Debian packaged versions.)in attempting to convert from OpenSCAD to STEP,
found the advice here and followed it:
https://forum.lulzbot.com/viewtopic.php?t=243
however the following file has all of its "difference" (removal)
objects turned into "unions" (additions):
http://hands.com/~lkcl/microdesktop_prog2.scad
- Attachments
-
- Screenshot from 2022-09-11 13-32-14.png (145.81 KiB) Viewed 962 times
Re: Problem OpenSCAD scad & csg files - PLEASE Add them to this thread - Thanks
That file contains an empty "union()" that appears to confuse FreeCAD -- we've got code to handle that condition, but it must not be working right. I'll try to take a closer look.