openSCAD import troubles.

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
bveina
Posts: 2
Joined: Wed Oct 21, 2020 1:44 pm

openSCAD import troubles.

Post by bveina » Wed Oct 21, 2020 2:23 pm

I'm having an unexpected issue with openSCAD imports.
while i have tried searching for similar issues on the forum, I've been unsuccessful, but I may not be familiar enough with the program to know what i should be searching for.

problem: i want to import an open scad model with colors into kicad.
subproblem: based on the internet the best way to do this is openSCAD->freecad-2-vrml->kicad.
sub sub problem: my model doesn't import correctly.

question 1) is the an example of the XY problem http://xyproblem.info/
question 2) is the below behavior expected?
question 3) is there a way to do this correctly without resorting to hull (described below)?
question 4) if i can get all this working, is there a reason that the colors are not importing into freecad?

Documentation:

I've reduced it down to a pretty minimal example, using this code you create a pillar with tapered ends:

Code: Select all

module SinglePin(size,TotalLen,Voffset=0)
{
  tipSize=size/2;
  union()
  {
    cube([size,size,TotalLen-2*tipSize]);
      
    translate([size/2,size/2,TotalLen-2*tipSize+Voffset])
      rotate([0,0,45])
        cylinder(tipSize,size/sqrt(2),size/sqrt(2)/2,$fn=4);
    
    translate([size/2,size/2,-Voffset])
      rotate([180,0,45])
        cylinder(tipSize,size/sqrt(2),size/sqrt(2)/2,$fn=4);  
  }
}
In openSCAD i create 4 different pillars:

Code: Select all

size = 1;
PinLength = 2;

// what i thought should work, but doesnt
color("red")
 translate([0,0,0])
  SinglePin(size=size, TotalLen = PinLength);
 
// not what i want but does render 
color("green")
 translate([2,0,0])
  SinglePin(size=size, TotalLen=PinLength, Voffset=.1);

// not what i want (again) but does render 
color("green")
 translate([4,0,0])
  SinglePin(size=size, TotalLen=PinLength, Voffset=-.1);
  
// what i want which works,
// but takes forever to render,
// and looses all the operation hierarchy of other options
color("yellow")
 translate([6,0,0])
  alternate(size=size, TotalLen=PinLength, Voffset=0);
  
 
open scad renders them as follows.
SCADRender.png
SCADRender.png (5.04 KiB) Viewed 71 times
to create the issue im having just open the scad file in freecad.
FreecadRender.png
FreecadRender.png (8.14 KiB) Viewed 71 times
hopefully the difference is obvious. the leftmost pillar doesnt have any tapered ends. even though the versions with inset or offset tapers do import correctly.

the yellow pillar is created by replacing the union in the singlePin module with a hull operation.

ive attached the entire scad to the post.

Thanks in advance.
Attachments
MinExample.scad
(1.46 KiB) Downloaded 2 times
bveina
Posts: 2
Joined: Wed Oct 21, 2020 1:44 pm

Re: openSCAD import troubles.

Post by bveina » Wed Oct 21, 2020 3:35 pm

To provide more detail ive also discovered an extra peculiarity:
if you remove the taper from the cylinder everything does import correctly.

new minimum working example attached: creates three copies using tapered and non tapered cylinders using offsets (-,0,+).
the straight cylinders union correctly with all 3 offsets, the tapered cylinders do not.
SCADRenderNoTaper.png
SCADRenderNoTaper.png (7.79 KiB) Viewed 58 times
FreecadRenderNoTaper.png
FreecadRenderNoTaper.png (12.27 KiB) Viewed 58 times
Attachments
MinExample.scad
(2.5 KiB) Downloaded 1 time
Post Reply

Who is online

Users browsing this forum: m0n5t3r, papyblaise and 17 guests