You need to use EasyEDA editor to create some projects before publishing
Export PCB design into 3D model to be used by 3D printer (OpenSCAD) - is it possible?
1670 3
YigalB 3 years ago
Now that my first PCB was recieved and working well, I would like to 3D print a specific plastic box with mounting for servos etc. Is it possible somehow to export the 3D model of my PCB to be used with OpenSCAD (3D design software)? This will allow perfect holes, screws locations, and make sure parts will be located physically without collision. Any ideas?
Comments
MikelSim 3 years ago
Hi, you can achieve this by converting the OBJ model, which can be exported now by the browser version of EasyEDA, to a STL model by using an online converter like e.g. [https://www.ofoct.com/3d-model-file-for-3d-printer-converter/3d-model-file-converter.html](https://www.ofoct.com/3d-model-file-for-3d-printer-converter/3d-model-file-converter.html). Currently, the model is exported in imperial units and with a PCB thickness of 2.54mm. To transform this into the metric system (mm) and to 1.6mm thickness, you can use my quick-and-dirty converter written in C# for cs-script. The converter works only with the text version of STL files, not the binary ones. The converter will "create" an origin at the lower left corner of the PCB. ``` using System; using System.Collections.Generic; using System.IO; using System.Globalization; // Compile to a console executable using cs-script. ([https://www.cs-script.net/](https://www.cs-script.net/)) class Script {     static void Main(string[] args)     {         if (args.Length.Equals(2))         {             if (File.Exists(args[0]))             {                 ConvertStlFile(args[0], args[1]);                 Console.WriteLine("Done.");                 return;             }         }         Console.WriteLine("Usage: EasyEDA_3D_Correction <Source STL file> <Destination STL file>");     }     static void ConvertStlFile(string SourcePath, string DestinationPath)     {         string[] readText = File.ReadAllLines(SourcePath);         string[] writeText = new string[readText.Length];         int i;         // Find the coordinates of the lower left corner of the PCB         double min_x = 1e12;         double min_y = 1e12;         if (readText.Length >= 65)         {             for (i = 0; i < 65; i++) // the first 8 facets contain the PCB outline?             {                 string[] token = readText[i].Trim().Split(new char[] { ' ' });                 if (token.Length > 0)                 {                     if (token[0].Equals("vertex"))                     {                         double x = 0.0;                         double y = 0.0;                         if (double.TryParse(token[1], NumberStyles.Number, new CultureInfo("en-US"), out x))                         {                             if (double.TryParse(token[2], NumberStyles.Number, new CultureInfo("en-US"), out y))                             {                                     min_x = Math.Min(min_x, x);                                     min_y = Math.Min(min_y, y);                             }                         }                     }                 }             }         }         for (i = 0; i < readText.Length; i++)         {             writeText[i] = readText[i];             string[] token = readText[i].Trim().Split(new char[] { ' ' });             if (token.Length > 0)             {                 if (token[0].Equals("vertex")) // only vertex lines contain coordinates                 {                     double x = 0.0;                     double y = 0.0;                     double z = 0.0;                     if (double.TryParse(token[1], NumberStyles.Number, new CultureInfo("en-US"), out x))                     {                         if (double.TryParse(token[2], NumberStyles.Number, new CultureInfo("en-US"), out y))                         {                             if (double.TryParse(token[3], NumberStyles.Number, new CultureInfo("en-US"), out z))                             {                                 x = (x - min_x) * 0.254; // move to X-Origin and scale to mm                                 y = (y - min_y) * 0.254; // move to Y-Origin and scale to mm                                 z = z * 0.254; // scale to mm                                 // 1.6mm board thickness instead of 2.54mm                                 if (z > (2.54 - 1.60)) // everything above the top layer (1.6mm)                                 {                                     z -= (2.54 - 1.60); // move down                                 }                                 // replace STL line                                 writeText[i] = string.Format(new CultureInfo("en-US"), "  vertex {0:0.000} {1:0.000} {2:0.000}", x, y, z);                             }                         }                     }                 }             }         }         // Store converted STL file         File.WriteAllLines(DestinationPath, writeText);     } } ```
Reply
Willem Burgers 2 years ago
@MikelSim Thanks for this cs-script. Although when I import the stl file that comes out of the conversion to tinkercad, I still don't see a board outline. Any help would be greatly appreciated.
Reply
andreasbernhofer 2 years ago
@Willem Burgers on Windows you can just open the *.obj file with integrated "3D Bilder" and then save as *.stl (and also reposition the origin). In OpenSCAD import with `scale(0.254) import("YourPCB.stl");`.
Reply
Login or Register to add a comment
goToTop
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus-@1x -mockplus-

Cookie Notice

Our website uses essential cookies to help us ensure that it is working as expected, and uses optional analytics cookies to offer you a better browsing experience. To find out more, read our Cookie Notice