Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Carsten Arnholm

Pages: [1] 2 3
General Discussion / Re: Planned new features in AngelCAD
« on: 2020-10-13, 15:18:42 »
Some more info of upcoming features

"Save & Close all but this" option when right-clicking editor tab.
Linux: Now opening default file browser when opening folder
Now displaying also stderr messages from applications running in thread background (xcsg/openscad)

Shortcut is now Ctrl+F like most other programs
Search now responds properly to pressing ENTER.

OpenSCAD import
OpenSCADs slightly esoteric options in 'linear_extrude', including twist,scale and slices will be supported. Also extrude with multiple children works.
Allow use of secant_tolerance (a.k.a 'sec_tol') to control discretization of imported models.
Added support for projection(cut=true).
Drag & drop of .scad files into AngelCAD IDE works.

AngelCAD version 1.4-00 was released 28 July 2020, so this post is a belated announcement of that fact. The post is made so that users know about the latest publically available version.

Windows and Ubuntu binaries at

Changes in this version
  • fixed missing member functions in spline2d and spline3d. This makes it possible to use spline curves directly in script code.
  • angelcad-samples: fixed segfault error for polygon & polyhedron
  • added new pointcloud to allow reading points from external files. This makes it easier to use external data to make for example a convex hull from a point cloud
  • added dxfread application to read DXF files. This is a stand alone console application that can convert 2d DXF files into an AngelCAD function for use in e.g. linear extrude
  • Windows version now built with MSVC2019. Now using an up to date Windows compiler to Build AngelCAD

General Discussion / Re: Planned new features in AngelCAD
« on: 2020-09-13, 09:38:00 »
Some more info on the upcoming features:

Processing of OpenSCAD files
I have now decided to make it easier to use AngelCAD for this purpose. Simply open an OpenSCAD .scad file in the AngelCAD IDE and press the build button. Note that this requires OpenSCAD to be installed on the computer, because it is being used to convert the .scad file to .csg (a fast process even for large models). The benefit is in the much faster processing of the boolean operations in xcsg.  Also, the AngelCAD viewer (AngelView) can then be used in the usual way in this scenario.

Remember which files are open
In version 1.4 or earlier only one file would be remembered and re-opened in the next AngelCAD session. I am working on a feature to remember and restore the complete set of source files that was open in the previous session.

Discovering file edits by other programs
Potentially, a source file opened by AngelCAD could be edited and saved by some other program (e.g. Notepad++) at the same time. In version 1.4 or earlier this would not be discovered by AngelCAD. Work is ongoing to make AngelCAD detect such edits and take proper action.

General Discussion / Re: Threads - ISO
« on: 2020-09-13, 09:20:54 »
Here's my code. the '//this line' comment, was left from when I was originally going to tap a plain hole, but if it is removed, or changed to the root diameter, the code fails.

This code as shown seems to run fine. It is not clear to me what '//this line'  is referring to so I am not able to reproduce. Which line number in the script?

General Discussion / Re: console mesages
« on: 2020-09-09, 16:54:16 »
I've not heard of polyfix, but will try it.

Polyfix is part of your angelcad installation, it is a console program. You find it in the same folder as AngelCAD is installed (you also find dxfread there). I recommend you set up the system PATH to include the AngelCAD installation folder.

usage: polyfix [-verbose] [-maxiter <str>] [-dtol <str>] [-atol <str>] [-lumps] [-nflip] [-remesh <str>] [-overwrite]
[-out <str>] [-zip] <input_filename>
 -verbose              Verbose messages
 -maxiter=<str>        [heal]          Max iterations (def=10)
 -dtol=<str>           [heal]          Distance tolerance (def=1.0E-2)
 -atol=<str>           [heal]          Area tolerance (def=1.0E-6)
 -lumps                [heal]          Split into lumps (not supported for stl output)
 -nflip                [heal]          Flip faces with inward normals (experimental)
 -remesh=<str>         [remesh]        Heal & remesh surfaces to given edge length (set dtol to small value ~1.E-6)
 -overwrite            [output]        allow file overwrite, including input file.
 -out=<str>            [output]        output filename/format (.obj, .off, .amf, .stl, .astl)
 -zip                  [output]        save output also to compressed zip file

General Discussion / Re: console mesages
« on: 2020-09-09, 07:07:02 »
run it through polyfix and see if it says anything useful,

General Discussion / Re: console mesages
« on: 2020-09-08, 22:44:19 »
I scrapped what i was doing, or at least the way i was trying to do it, and came up with this (part of a generic wheel creator I am thinking about). It produces rounded ends on tubes, and can be extended for straight slabs, too. The secret is in the polygon shape. The one shape allows inside and outside ends of a tube to be rounded. It seems quite robust, for once, for me. Instead of the polygon, then a square at 45deg, would chamfer the ends. Obvious limits in the relationship between the fillet diameter and inside diameter of the tube using this

This is a great example, well done! It is a clever way of making rounded ends! I attached an image of your result. If you use a less aggressive secant_tolerance it runs much faster without compromising the result very much.

Code: [Select]
void main()
   shape@ obj = main_shape();

General Discussion / Re: console mesages
« on: 2020-09-08, 22:38:02 »

edit, adjusted secant tolerance, and got this, as last two lines.
Code: [Select]
...Info: rotate_extrude angle>=2*PI implies a torus
xcsg finished with exception: (carve error): D:\cpde_dep\3rdparty\carve\lib\intersect_face_division.cpp:587  "implement me"

which most likely is a clue.

Yes, things like this happen from time to time, although I have not seen that one before. AngelCAD uses the Carve library internally, and sometimes that fails. Apparently you found something that isn't fully implemented. Carve is great and much faster than CGAL, but it does act up sometimes. Usually a failure like this can be tweaked by slight redesign, or taking a different approach as you did.  I may have a look at that piece of code and see if there is anything I can do.

Whan Carve fails it either throws an exception, then you get a proper message. But it happens that it fails withouth an error message and that can leave you wondering, I agree.

Today you can do this

Code: [Select]
shape@ main_shape()
   // create cube & 3 small cubes - the way I'd like it
   double d = 100;
   solid@ mycub = cube(d);
   solid@ hole = cube(2);
   @mycub = mycub - translate(5,10,d-2)*hole;
   @mycub = mycub - translate(90,5,d-2)*hole;
   @mycub = mycub - translate(50,50,d-2)*hole;
   return mycub;

What you are asking for would look like this (NOTE: code below does not work in AngelCAD 1.4)

Code: [Select]
shape@ main_shape()
   // create cube & 3 small cubes - the way I'd like it
   double d = 100;
   solid@ mycub = cube(d);
   solid@ hole = cube(2);
   @mycub -= translate(5,10,d-2)*hole;
   @mycub -= translate(90,5,d-2)*hole;
   @mycub -= translate(50,50,d-2)*hole;
   return mycub;

I.e. "syntactic sugar" where the above statement

Code: [Select]
@mycub = mycub - translate(5,10,d-2)*hole;
using a "subtraction assignment" operator it becomes

Code: [Select]
@mycub -= translate(5,10,d-2)*hole;
Compund assignment operators such as -= and += are currently (version 1.4) not supported in AngelCAD for shape@ objects. Is it important?

General Discussion / Planned new features in AngelCAD
« on: 2020-09-06, 22:41:56 »
Here is a quick summary of things coming to AngelCAD. This thread is for discussing already planned features as listed. If you want to propose new features, feel free to start a new thread with a suitable subject heading.

Import of DXF files
This is not a language feature, but instead an external application (dxfread) that can be used alone, or from a new File -> Import DXF .. menu item in the AngelCAD IDE. When used, it generates an AngelCAD *.as file containing a function returning a shape2d@ object that you can use with linear_extrude, rotate_extrude, sweep etc.  For example, if you have a file "nice_drawing.dxf" and import it, you get a file "" containing a function with signature

Code: [Select]
shape2d@ nice_drawing_dxf();
In your main AngelCAD script you include the file

Code: [Select]
#include ""
And then call the nice_drawing_dxf() as required.

Support for script arguments
This allows some of the script variables to be defined outside the script. The variables become available via the the "args" input argument of the main_shape() function, and the script can extract the values as shown below and in the attached screenshot. If the variable is not provided by the user, a default value is specified in the script

Code: [Select]
// AngelCAD code.
#include ""

shape@ main_shape(as_args@ args)
   double height = args.get_unsigned_double("height",def:1.0);
   return linear_extrude(DXF447_dxf(),height);

Optional "post-build" export of generated files to a predefined directory
Using this option, a disk folder can be defined as the export directory for generated files, regardless of where the AngelCAD source is executed. This is a convenient feature where for example your slicer program can pick up STL files.

Processing of OpenSCAD csg files in AngelCADs xcsg engine
If you have an OpenSCAD .scad file, for example  "myfile.scad", you can use OpenSCAD to generate "myfile.csg"

$ openscad --o myfile.csg myfile.scad

The above is a fast process, even for large models because no boolean operations are involved (CGAL is not involved). Given the generated .csg file, you will then be able to use it as input to AngelCADs xcsg engine and create e.g. an STL file ! :

$ xcsg --stl myfile.csg

This can be many times faster than doing it directly in OpenSCAD. Granted, there are some limitations, not all .csg commands will be supported. This includes import,  surface, text and resize and some other things. But many models do not use these features, and sometimes this can be a big time saver. There is also a possibility that using this feature from the AngelCAD IDE might become possible, no decision yet.

General Discussion / Re: rendering of imsges
« on: 2020-09-06, 22:19:22 »
I recommend oversizing things you subtract, for example like this

Code: [Select]
// AngelCAD code.

shape@ main_shape()
   // create cube & sphere in default positions
   solid@ tube = cylinder(30,10);
   solid@ shank = cylinder(10,7.5);
   solid@ shaft = cylinder(30,4);
   solid@ fix = rotate_y(90)*cylinder(250,1,center:true);
//drill the two fixing holes straight through tube
   return tube-shank-shaft - translate(-20,0,4)*fix -translate(-20,0,22)*fix;

void main()
   shape@ obj = main_shape();

General Discussion / Re: a simple clip
« on: 2020-08-29, 09:16:53 »
I ran into a problem, because the ends of the coil are not cut on the x/y plane, which presents an angle to the two end pieces. I added an overlap to remove the gap, but found that It would not complete for wire diameters over 2.0, or so. I fudged it again, by making the end pieces slightly larger. This works, but it is not particularly elegant. It would be better to generate  a path from end to end, and extrude along that. However, these loops are now holding up my tomato plants, and smaller ones will be used as cable clips on the printer as originally intended. They print OK, lying flat, with a few supports.

Nice work! The problem you describe is a classic one. In AngelCAD (and also OpenSCAD), the solid geometry is represented as a surface mesh, i.e. the surface of the solid is described by flat polygons, usually of the simplest variant; triangles.

You can not perfectly describe the surface of a coil like that using a triangle surface mesh, it is just an approximation. Likewise, you cannot perfectly describe the surface mesh of a straight cylinder using a triangle surface mesh, it is another approximation. When you try to union the two at the coil/cylinder ends you typically run into a problem: the two approximations are not the same and therefore the mating of the two can often fail, and you have to make tweaks like you did to make it work.

Having realised this, the solution is often to try a different approach where the problem of incompatible cylindrical end approximations are avoided. One way is to sweep the whole shape in a single operation:

Code: [Select]
// AngelCAD code.

shape@ main_shape()
   double wirediam = 3.0;
   double gripdiam = 8.0;
   return coil(wirediam,gripdiam);

solid@ coil(double wirediam, double gripdiam)
   // NOTE: This code has some kind of bug in creating 3d spline that
   // makes the coil radius twice what it should be
   // I have therefore made some tweaks to adjust for that.
   // The bug should be investigated...
   // create the profile to be swept
   double radius    = (gripdiam +wirediam)/4.0;
   shape2d@ profile = translate(radius,0)*circle(wirediam/2);
   double len   = 2*radius + wirediam/2;
   double pitch = wirediam*1.1;
   pos3d start(radius,0,-len);
   pos3d end(radius,pitch,len);
   // create the 2 first spline points
   array<pos3d@> points = { start, (start+pos3d(radius,0,-len/2))*0.5 };

   // create points around the coil
   for(double angle=0.0; angle<=2*PI; angle+=PI/9.) {
      double x = radius*cos(angle);
      double y = pitch*angle/(2*PI);
      double z = radius*sin(angle);
      points.push_back( pos3d(x,y,z) );
   // create the 2 last spline points
   pos3d@ p = points[points.size()-1];

   // create the spline
   spline_path@ path = spline_path(points,vec3d(0,1,0));
   solid@ ball= sphere(wirediam/1.2);
   // create the coild and add the balls
   return sweep(profile,path) + translate(start.x()*2,start.y(),start.z())*ball
                              + translate(end.x()*2,end.y(),end.z())*ball;

void main()
   shape@ obj = main_shape();

Here, we create a 3-dimensional spline curve that describes the central line through your coil, including the semi-straight ends. Then we use AngelCADs sweep function to sweep the circle along that spline path. This means we do not have to add the cylindrical ends, and therefore we do not have any problems with incompatible surface mesh approximations.

Using AngelCAD / Re: AngelCAD on Thingiverse
« on: 2020-08-29, 07:15:44 »
Although AngelCAD being listed as a design tool on Thingiverse would be nice I don't see any need to use a lot of energy to make it happen. If it it listed as a desgn tool it is because a sufficient numbers of users start using the software, and not the other way around.

These days Thingiverse seems less imprtant than before. There used to be useful statistics about what people were viewing, but it looks like that almost brought their servers to their knees, so they removed it. That makes it harder to find popular designs, so you end up finding what used to be popular before, i.e. not many new things are happening there.

You raise many points Will, good stuff. I guess we can address them one by one.

Just to make a quick demo of simulated CNC simulation in AngelCAD, I threw together the following code. See attached image for what it looks like when run. Obviously, it is conceivable to use the same paths to generate CNC G-code

Code: [Select]
// AngelCAD code.
// Simulating CNC with AngelCAD

// signature of a function returning the path of a single character
funcdef array<pos2d@> letter_func(double height);

// the path for engraving the letter 'C'
array<pos2d@> letter_C(double height)
   array<pos2d@> path;
   for(double angle=PI/2; angle<3*PI/2; angle+=PI/18) {
      double x = 0.75*height*0.5*cos(angle);
      double y = height/2 + height*0.5*sin(angle);
   return path;

// the path for engraving the letter 'N'
array<pos2d@> letter_N(double height)
   array<pos2d@> path = {
      , pos2d(0,height)
      , pos2d(0.75*height,0)
      , pos2d(0.75*height,height)
   return path;

// function to create the solid for a single character
solid@ letter(letter_func@ f, double height)
   // we use a spherical engraving tool
   solid@ s = sphere(8);
   // get the 2d path and the start position
   array<pos2d@> path = f(height);
   pos2d@ p0 = path[0];

   // place the engraving tool in the start position
   solid@ tprev = translate(p0.x(),p0.y())*s;
   // 'body' will contain our letter
   solid@ body  = null;

   // traverse the path and build the whole letter body
   for(uint i=1; i<path.size(); i++) {
      pos2d@ p = path[i];
      solid@ t = translate(p.x(),p.y())*s;
      // create a straight segment using hull3d
      // from previous and current position bodies
      solid@ edge = hull3d(tprev,t);
      // update the previous body
      @tprev = t;

      // add current segment into body
      @body = (@body == null)? edge : body+edge;
   // letter is complete
   return translate(0,height/2)*body;

shape@ main_shape()
   // create a metal work-piece
   double thickness = 30;
   solid@ metal_piece = translate(0,0,-thickness)*cuboid(dx:280,dy:180,dz:thickness);
   // define height/with of letters
   double h = 80;
   double w = h*0.75;
   // create the letter bodies
   solid@ C1 = translate(w,0)*letter(letter_C,height:h);
   double dx = w +;
   solid@ N  = translate(dx,0)*letter(letter_N,height:h);
   dx += w +;
   solid@ C2 = translate(dx,0)*letter(letter_C,height:h);
   // engrave 'CNC' into the metal piece
   return metal_piece - (C1+N+C2);

void main()
   shape@ obj = main_shape();

General Discussion / Re: Plans for the future of AngelCAD?
« on: 2020-08-25, 20:29:02 »
Guys, the talk about CNC machining is interesting, but it does not really belong in a thread about future plans for AngelCAD.
If you want to discuss CNC machining further you are welcome to do so, but please open a thread about CNC machining and discuss it there.

Pages: [1] 2 3