Home 3D Printing MatterCAD – Design Your 3D Components In C#

MatterCAD – Design Your 3D Components In C#

0
MatterCAD – Design Your 3D Components In C#

[ad_1]

Any programmer wanting or needing to mannequin customized 3D elements has in all probability stumbled throughout OpenSCAD, a program that permits you to generate elements utilizing primary scripting.  OpenSCAD is a superb instrument and for some time we used it completely in designing elements, however we missed the power to make use of a completely featured programming language.  Ultimately we began making a homegrown utility that will permit us to jot down an element utilizing C# – we name the utility MatterCAD.  For our design workflow we use MatterCAD to output a .scad file which we will then open in OpenSCAD.  OpenSCAD is used to do the visualization and to do the ultimate outputting of a printable .stl file.

Over time MatterCAD has continued to advance to the purpose have been it’s in all probability helpful and steady sufficient to be made generaly out there.

Options:

MatterCAD is designed to make the creation of elements simpler with two fundamental options.  The primary characteristic is the power to deal with every half, or assortment of elements, as distinct objects within the code.  Treating every half as an object permits data to be saved concerning the half – attributes like its bounding field, place and transforms.  The opposite fundamental characteristic is a wealthy set of positioning instruments, equivalent to ‘align’ and ‘set middle’.  With these positioning instruments you may outline elements relative to one another or to a selected coordinate place on this planet.  For instance you may align the underside of an element with the Z 0 aircraft of the world, that means you may make sure that half will all the time keep at Z 0 whatever the modifications you make to its design.  With ‘align’ you may also structure elements relative to different elements.  Once more, while you change the scale or place of 1 half, all of the elements which can be aligned to it merely transfer to their right positions relative to the one which has modified.

  • Primitives
    • Field
    • Cylinder
    • NGonExtrusion
    • RotateEtrude
    • Spherical
    • Strong
    • Sphere
  • Operations
    • Union
    • Distinction
    • Intersection
  • Transforms
    • Align
    • Rotate
    • Scale
    • SetCenter
    • Translate

 

Assets You Will Want:

You possibly can obtain the supply code from our bitbucket account.  The file you will have is MatterCadCommandLine.zip

Additionally, you will want an IDE (built-in growth atmosphere) to edit the code.  We recomend you utilize MonoDevelop.  MonoDevelop is out there for Home windows, Mac and Linux.  You may also use VisualStudio when you’ve got it however it’s not as simple for everybody to get.

You’ll want to have a look at the API for MatterCAD.

And at last you will have a replica of OpenSCAD to view your half and to output it to an .stl for printing.

Work Stream:

Here’s a fast breakdown of the process we take when creating a brand new half.  That is assuming you will have already downloaded MatterCAD and an IDE (built-in growth atmosphere) like MonoDevelop.

  1. Go into the ‘MatterCadCommandLine’ listing
  2. Copy one of many folders, we’ll use the TrackConnector folder (choose it and hit copy paste)
  3. Rename the folder to the brand new half you need to create.  We’ll use ’10mmBox’ for now
  4. Go into the brand new folder (double click on ’10mmBox’)
  5. Open ‘MatterCad.sln’ (this could launch MonoDevelop)
  6. Open ‘MatterCad.cs’ from inside the MonoDevelop
  7. Choose the contents of the TrackConnector() perform and exchange them with ‘return new Field(10, 10, 10);’
  8. Construct and Run this system (we are going to assume you make a debug construct for now)
  9. Again in your file supervisor, go into the ’10mmBoxbinDebug’ folder and open the file ‘TrackConnector.scad’ with OpenSCAD (you may give a differnt output file title in Primary() later).
  10. Now to enhance the design you’ll edit the code, run this system once more after which simply reload (F4) the half in OpenSCAD.  Wash, Rinse and Repeat (try this again and again :).

Pattern Script:

Here’s a quite simple script.  It’s a monitor connector for a picket practice set.

utilizing System; // we'd like some usings to get began
utilizing System.Diagnostics;
utilizing MatterHackers.Csg; // our constructive strong geometry base courses
utilizing MatterHackers.VectorMath; // helper math features
namespace SimplePartScripting
{
    static class SimplePartTester
    {
        static CsgObject TrackConnecor()
        {
            // CsgObject is our base class for all constructive strong geometry primitives
            CsgObject whole; 
            // we create a field object and title it bar, the "hyperlink" is the title it is going to
// have in OpenSCAD
            CsgObject bar = new Field(20, 5.8, 12, "hyperlink");  
            // we set it is middle to the middle of the coordinate system
            bar = new SetCenter(bar, Vector3.Zero);            // and we make the entire = bar, the one object now we have right now
            whole = bar;            // now we make a cyliner for one facet
            CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z); 
            // place it the place we would like it
            leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0)); 
            // and make one other one on the opposite facet by mirroring
            CsgObject rightHold = leftHold.NewMirrorAccrossX(); 
            // that is the best way we truly determine what boolean operation to make use of to place them collectively
            whole += leftHold; 
            whole += rightHold; 
            return whole;  // and go it again to the caller
        } 
        static void Primary()
        {
            // an inner perform to avoid wasting as an .scad file
            OpenSCadOutput.Save(TrackConnecor(), "TrackConnector.scad");
        }
    }
}

[ad_2]