OpenSCAD: detect it's running in FreeCAD?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
Post Reply
le_top
Posts: 20
Joined: Sat Apr 24, 2021 2:13 pm

OpenSCAD: detect it's running in FreeCAD?

Post by le_top »

Summary:
OpenSCAD scripts can read 'version()' and 'version_num()' to get an idea about the tool version, but there does not seem to be anything to learn more about the tool it runs in.
Is there any function/variable or method to detect that the script is running in FreeCAD?

Detail:
I've been diving into openscad in combination with Freecad for different topics related to PCB design.

Using FreeCAD to get STEP files works with some limitations, one of the limitations being that there some issues extruding text.

I would like to test if the OpenSCAD script is running in FreeCAD or OpenSCAD and adjust the includes items accordingly.
I suppose that FreeCAD's support will improve so that in the future I can enable disabled features.

For example, the following is a screenshot of a model rendered in OpenSCAD, but it does not render properly in FreeCAD due to the extruded text.
Image

In FreeCAD it renders like this :
Image

The code is disabled like so:

Code: Select all

   if(0){ 
    translate([-3.55*8-0.3,0.60,case_h/2-case_d])    
     color(text_c)
       linear_extrude(0.001) {
         text(line1, size=5.55*0.95, font=LCDFONT);
       };

    translate([-3.55*8-0.3,-5.55-0.4+0.6,case_h/2-case_d])    
      color(text_c)
        linear_extrude(0.05) {
          text(line2, size=5.55*0.95, font=LCDFONT);
        };

The question is not about the rendering issue, but about a method to detect that the script is running in FreeCAD.
Post Reply