openscad problem

Post here for help on using FreeCAD's graphical user interface (GUI).
trampas
Posts: 12
Joined: Fri Aug 05, 2016 1:58 pm

openscad problem

Postby trampas » Tue Jan 10, 2017 2:13 pm

I am trying to run this enclosed openscad script in freecad 0.17 8046 (windows 10 x64) and it shows red explanation marks on the objects.

I am relatively new to FreeCAD so most likely I am doing something wrong.
Attachments
right angle gears.scad
(18.72 KiB) Downloaded 8 times
keithsloan52
Posts: 471
Joined: Mon Feb 27, 2012 5:31 pm

Re: openscad problem

Postby keithsloan52 » Tue Jan 10, 2017 9:43 pm

trampas wrote:I am trying to run this enclosed openscad script in freecad 0.17 8046 (windows 10 x64) and it shows red explanation marks on the objects.

I am relatively new to FreeCAD so most likely I am doing something wrong.


I don't think you are doing anything wrong I think you have just hit a difficult bug.

Looking at the code it is in an area that has given problems in the past. There are a number of options in the OpenSCAD preferences that have been used in the past to deal with difficult files see comments in the code. You could try the OpenSCAD option Use Multmatrix Feature but I doubt it will make any difference as the code is barfing at trying to to do a multmatrix transformation on a null shape

"/Applications/CAD/FreeCAD.app/Contents/Mod/OpenSCAD/importCSG.py", line 802, in p_multmatrix_action
new_part.Shape = part.Base.Shape.transformGeometry(transform_matrix)
<class 'Part.OCCError'>: Cannot transform null shape.

All the explanation marks are boolean operations that have not worked and I therefore suspect the null shape. At a guess these are problems with OCC and boolean operations on the fustrum shapes as most seem to involve a fustrum

You might have better luck with a later version of OCC my version is
OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Release
Branch: tag: 0.16.6706
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.8.0.oce-0.17

I am sure in at least the distant past there was an option to do a refine_shape operation after each boolean operation which might help trying to avoid do a transformation on a null shape. Doing a refine_shape after each boolean slows things down even further, but was a sticking plaster when booleans had OCC errors in the past. Obviously better if OCC fixed the error at source though. OCC did go through a stage of fixing a lot of errors. I will look again at the code tomorrow but doubt there will be able to fix in the short term. :-(
keithsloan52
Posts: 471
Joined: Mon Feb 27, 2012 5:31 pm

Re: openscad problem

Postby keithsloan52 » Tue Jan 10, 2017 10:29 pm

Okay I sort of spoke too soon

Select the OpenSCAD workbench then go to preferences. Change "Maximum number of faces in polygon (fn)" to something like 6. Load your file and be very patient it will take a long time. Obviously there is a OCC bug with smooth frustrums that this gets round. ( Having fn = 0 creates smooth frustrums.)

I know still no cigar :-( as the original scad files has two gears and I now only have one. At the moment no idea why that should be. Would attach file but deemed too large at 3.2Mb
User avatar
NormandC
Posts: 11701
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: openscad problem

Postby NormandC » Thu Jan 12, 2017 5:30 am

keithsloan52 wrote:I am sure in at least the distant past there was an option to do a refine_shape operation after each boolean operation

It's still there in Preferences / Part design / General.
User avatar
NormandC
Posts: 11701
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: openscad problem

Postby NormandC » Thu Jan 12, 2017 5:49 am

keithsloan52 wrote:I know still no cigar :-( as the original scad files has two gears and I now only have one.

I have both.

I'm puzzled by the Matrix_Deformation's purpose which scales down the gears. Why not parametrize them to the correct scale in the first place?

From my file it's a simple matter to only keep "difference" and "difference001", create Image Draft Clones from them and scale the clones to the correct size.

Dropbox download link: right angle gears scad_normandc1.fcstd (3.1MB)

FreeCAD info:
OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9592 (Git)
Build type: None
Branch: master
Hash: c2f2a250549163947592069262ce1cd3328b3669
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
FC_right angle gears scad.png
FC_right angle gears scad.png (46.99 KiB) Viewed 111 times
keithsloan52
Posts: 471
Joined: Mon Feb 27, 2012 5:31 pm

Re: openscad problem

Postby keithsloan52 » Thu Jan 12, 2017 11:55 am

NormandC wrote:I'm puzzled by the Matrix_Deformation's purpose which scales down the gears. Why not parametrize them to the correct scale in the first place?


ImportCSG works on an exported CSG that that is produced under the covers. It then has to parse the CSG statements and create objects as per the procedural language dictates
cron