Opening an .scad file its parts are put to the wrong coordinates on screen

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
infocean
Posts: 17
Joined: Tue Nov 13, 2018 4:41 am

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by infocean »

Thank you folks, looks like you do great progress on this post.

I am using a Mac 10.15.7 Catalina, my OpenSCAD is 2020 01 and my FreCAD is 0.19. The program I uploaded is slightly different from the program I made the first set of pictures, but the problem, the misplacement of the parts are the same. So whatever the uploaded program is creating, use that for your testing and ignore the pictures I attached to the first post.

What do you think 0.20 will be out? Or what is your estimate for a fix for 0.19 ? Unfortunately Apple is not keen to update Python in older OSs, mine has:
janos@MacPro ~ % python --version
Python 2.7.16

and I do not want to mess too much with the official release of the OS.

Now, that is interesting, that TechDraw workbench is creating the 2D image right although the representation after the import is wrong. Does TechDraw work from the original .scad file? Or there is a hidden representation made by the OpenSCAD workbench and Tecdraw is using that hidden representation?

Thanks again,
Infocean
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by chennes »

infocean wrote: Tue Apr 13, 2021 6:42 pm What do you think 0.20 will be out? Or what is your estimate for a fix for 0.19 ?
0.19 was just released a few weeks ago, so 0.20 is still a way off. Your best bet if you need this in the short term is to grab the two files I linked to and replace the files in your FreeCAD distribution with them. You should be able to right click or option-click on FreeCAD in your Applications folder and choose "Show Package Contents". That will open up a folder that contains Resources -> Mod -> OpenSCAD, which contains all of the Python sources for that workbench. The two linked files replace the files in there with those names.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by keithsloan52 »

chennes wrote: Tue Apr 13, 2021 6:59 pm
infocean wrote: Tue Apr 13, 2021 6:42 pm What do you think 0.20 will be out? Or what is your estimate for a fix for 0.19 ?
0.19 was just released a few weeks ago, so 0.20 is still a way off. Your best bet if you need this in the short term is to grab the two files I linked to and replace the files in your FreeCAD distribution with them. You should be able to right click or option-click on FreeCAD in your Applications folder and choose "Show Package Contents". That will open up a folder that contains Resources -> Mod -> OpenSCAD, which contains all of the Python sources for that workbench. The two linked files replace the files in there with those names.
Or if you are not happy doing as Chris advises install Workbench https://github.com/KeithSloan/OpenSCAD_Alt_Import using the Addon Manager as per the instructions in the Readme. With it installed use FreeCAD | File | Open your file and you should get a prompt as to which importer to use.

I too am using a Mac 10.15.7 Catalina, my OpenSCAD is 2020 01 and my FreeCAD is 0.19.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by keithsloan52 »

infocean wrote: Tue Apr 13, 2021 6:42 pm Now, that is interesting, that TechDraw workbench is creating the 2D image right although the representation after the import is wrong. Does TechDraw work from the original .scad file? Or there is a hidden representation made by the OpenSCAD workbench and Tecdraw is using that hidden representation?
No idea. How are you requesting TechDraw deals with the scad file?
If I open the scad file from the TechDraw workbench it just invokes the OpenSCAD importer
295C58F7-CC9C-429F-81DA-16BA0196371E.jpeg
295C58F7-CC9C-429F-81DA-16BA0196371E.jpeg (149.21 KiB) Viewed 1146 times
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by keithsloan52 »

Attached is a Saved FreeCAD file created by importing your file https://www.dropbox.com/sh/q042ff66mw18 ... 2LNGa?dl=0
infocean
Posts: 17
Joined: Tue Nov 13, 2018 4:41 am

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by infocean »

Nice work Chris!

I am all set at this moment. As I read the manual it says, that I do not need to be in the OpenSCAD workbench to open an .scad file. Because I do not do any additional work in that workbench, I go to the TechDraw workbench immediately to create the 2D images. Much simpler then retrace the .scad created image in InkScape.

In TecDraw I just insert a page using a template, then I select all parts I need in the Combo view and hit the Insert a View button. Aster the insert I scale it to fit on the template nicely and half the thickness of the lines. That is it. Now I have to learn how to att annotations and comments and numbers, but that will be the easier part I guess.

It would be nice if the 2D drawing could have been done in OpenSCAD, but I have not seen anything related to that.

About 2 years ago I looked at FreeCAD, but there was something missing in it what I thought I need and went with OpenSCAD. Looks like, here on I need to work with both. :D

Thanks again,
Infocean
Attachments
Screen Shot 2021-04-13 at 7.09.17 PM.png
Screen Shot 2021-04-13 at 7.09.17 PM.png (44.91 KiB) Viewed 1125 times
infocean
Posts: 17
Joined: Tue Nov 13, 2018 4:41 am

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by infocean »

Looks like my satisfaction was premature. The problem now is the import of cross sectioned models from OpenSCAD.

The model in OpenSCAD was rendered with F6 without any complain. The FreeCAD import cuts some of the modules, but leaves others intact. FreeCad also shows some 2D structures, not really present in the original file. The cat was done in OpenSCAD like this:

difference(){
union(){
module1();
module2();
.....
.....
modulen();
}
translate([0,-25,12.5])
rotate([0,90,0])
linear_extrude(height=70,center=false,convexity=10)
polygon([[0,0],[25,0],[25,25],[0,25]]);
}
Question : Can I do the cross-section cut inside FreeCAD after the import of the .scad file?

Thanks ahead,
Infocean
Attachments
This is how FreeCAD  see it from the top
This is how FreeCAD see it from the top
Screen Shot 2021-04-19 at 4.18.27 PM.png (176.99 KiB) Viewed 1074 times
This is how FreeCad see it, my guess is from the side.
This is how FreeCad see it, my guess is from the side.
Screen Shot 2021-04-19 at 4.18.07 PM.png (153.47 KiB) Viewed 1074 times
This is how OpenSCAD see it from the top.
This is how OpenSCAD see it from the top.
Screen Shot 2021-04-19 at 4.17.52 PM.png (53.36 KiB) Viewed 1074 times
This is how OpenSCAd see it from the side
This is how OpenSCAd see it from the side
Screen Shot 2021-04-19 at 4.17.38 PM.png (66.67 KiB) Viewed 1074 times
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by chennes »

The extra 2D structures are coming from a few places in the importer where an object used in another operation is not being correctly hidden. I'll get those taken care of as I work my way through the unit tests. No ETA on that, though.

Regarding the cut -- are you able to post your OpenSCAD file here? Or a pared-down version of it that exhibits the problem?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
infocean
Posts: 17
Joined: Tue Nov 13, 2018 4:41 am

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by infocean »

Hi Chris,

I can send you the file privately, if that is OK. Were you able to see the crash log piece I sent earlier the same way?
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Opening an .scad file its parts are put to the wrong coordinates on screen

Post by chennes »

Yes, that's totally fine. I saw your crash log, but it doesn't give much of a clue about what was going wrong: something failed inside OpenCASCADE, but that's a pretty broad range of problems!
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply