Recent Posts

Pages: [1] 2 3 4
1
General Discussion / Re: a first stab at something useful
« Last post by Carsten Arnholm on 2020-08-12, 06:15:25 »
The console window height is resizeable. Grab the edge between it and the editor and resize it.

importing dxf is a 2-step process-

1. outside AngelCAD, run 'dxfread' in a terminal window to generate an AngelCAD function from it
$ dxfread -asfunc myfile.dxf
this generates a file myfile.as containing the profile from DXF.

Note: You must set up the PATH in windows or linux so the system, finds dxfread.

2. in AngelCAD, include the generated file

#include "myfile.as"

Then, somewhere in your code, call

shape2d@ profile = myfile();

obviously you can linear_extrude it.
2
General Discussion / Re: a first stab at something useful
« Last post by raymw on 2020-08-11, 21:56:30 »
I didn't see the warning messages, since they scrolled up through the narrow window at the bottom of the editor. I noticed the various 'red text', marking errors in my script, when they occurred,  but as the final lines said everything was OK, i never bothered to scroll back through. I've set the array to zero, as you suggested, and now no warnings. Is it possible to import dxf files?
3
General Discussion / Re: a first stab at something useful
« Last post by Carsten Arnholm on 2020-08-11, 19:01:40 »
Assuming you have not added the stands.resize(0); statement as suggested above, press F5 to see the warning messages.

F5 is the same as Build -> Compile AngelScript
F6 does the same as F5, but also runs XCSG to build the final STL. Then you can miss such warnings unless they are serious to cause a stop in compilation.
4
General Discussion / Re: a first stab at something useful
« Last post by raymw on 2020-08-11, 18:43:22 »
Thanks, I never actually saw the warning messages. I test printed the boxes as I wrote the code,  I have about 18 pla boxes, not many any use (trying to sort the printer out at the same time). I've now added rounded edges, and tried to do rounded corners, too, but not much success there. Easier to use a bit of sandpaper! I don't think I'll 'counterbore' the screwholes.
5
General Discussion / Re: a first stab at something useful
« Last post by Carsten Arnholm on 2020-08-10, 19:06:31 »
Hello and welcome to the forum!

Very nicely made box! I have attached an image made from it. One thing to note are these warnings you get at the end of the compilation:

Orphaned object = 0x5574545bbac0
Orphaned object = 0x557454615f20
Orphaned object = 0x55745461d570
Orphaned object = 0x55745461d950


The reason for this is that you have declared an array<pos2d2> in the global scope. That means the array lives beyond the end of main(), and therefore you get a warning for each object in the array when main() returns. This does no harm though, it is merely information. You can, however eliminate the warnings yourself by erasing the array at the end of main(), like this:

void main()    //put all the parts together
{
   solid@ both=boxholed()+translate(0,y+3+wall+wall,0)*lidholed() +fix()+standoffs();
   both.write_xcsg(GetInputFullPath(),secant_tolerance:-1.0);
   stands.resize(0);  // <-- clear the array contents by resizing it to zero length
}

6
General Discussion / a first stab at something useful
« Last post by raymw on 2020-08-07, 20:49:26 »
I've only been playing around with angelcad for a few weeks, but I like the structure so far, and the ood aspects of it. Not having a background in c++, I find the syntax somewhat confusing, but I know that will change as I had a load of help from Carsten. I thought I'd show a component box, which can be 3d printed. It is designed such that sizes, ventilation, standoffs can be readily changed. Depending on the quality of the 3d print, you may need to adjust the 'shave' value, so that the lid fits nicely. I recently added rounded corners to the lid, (thinlid, in code) because often internal corners of 3d prints are not sharp. There are other alterations I may or may not make, and if anyone wants to modify or otherwise use it, feel free to do so.

 
Code: [Select]
// AngelCAD code.

//inside dimensions of box
   double y= 45;
   double x= 51;
   double z= 15;
//wall thickness   
   double wall=2.5;
// x1,y1,x3,y3 defines corners of ventilation hole area
   double x1= 15;
   double y1=15;
   double x3=36;
   double y3=30;
//hole is width of inividual ventilation hole   
   double hole =3;
//space is hole spacing   
   double space= 5;
//select if you want want ventialtion holes in box or lid  or both 
   bool lidhole = true;
   bool boxhole = false;
//soh is standoff height, sod is standoff diameter   
   double soh = 5 ;
   double sod = 6 ;
//shole is diameter of hole in centre of standoff   
   double shole = 2;
// son is number of standoffs
   int son =4;
// if you add more standoffs, adjust number 'son', above.
// if you don' twant standoffs, set son to 0, but leave values in stands
// (x,y) position of standoffs 'stands'
   array<pos2d@ > stands  = {
     {6,6},
     {45,6},
     {6,39},
     {45,39}
     };
//shave is to give clearance for lid lip
//value of shave may depend on manufacturing method.   
  double shave=0.5;
 
 
 // fixed values below........
 // no need to edit values below here
 //*******************************************
 
 // w2 is half the wall thickness
   double w2= wall/2;
   
solid@ box()   //create box
{
   //smaller cuboid for inside
   solid@ boxis = cuboid(x,y,z+wall, false);
   // add walls to create outside of box
   solid@ boxos = cuboid(x+wall+wall,y+wall+wall,z+wall,false);
   //subtract inner from outer
   solid@ crate= translate(-wall,-wall,-wall)*boxos -boxis;
   //add lip to top size (0.5*wall) on outer edge
   solid@ lip= cuboid(x+wall+wall,y+wall+wall,wall) -translate(w2,w2,0)*cuboid(x+wall,y+wall,wall);
  solid@ all= translate (-wall,-wall,z-w2)*lip +crate;
return all;
}

solid@ thinlid(){
   
  //puts a 1mm radius on lip of inserted top
shape2d@ top= offset2d (rectangle (x+wall-shave-2,y+wall-shave-2),r:1);
return transform_extrude (top,translate(0,0,w2)*top);
   }

solid@ lid()  //similar to box, but only half wall high rim
{
  solid@ topbig = cuboid(x+wall+wall,y+wall+wall,w2, false);
   //add insertedhalf wall (make it shave smaller to fit inside lip of box)
   
   solid@ topall =topbig + translate(w2+1+(shave/2),w2+1+(shave/2),w2)*thinlid();
   // add lid holes (diam 1.3 * shole) in corners for fixing screws
   double r = (1.3*shole)/2;
   double hr =shole/2;
   solid@ h1 = translate (hr+wall,hr+wall,-wall)*cylinder(20,r);
   solid@ h2 = translate (hr+wall,y+wall-hr,-wall)*cylinder(20,r);
   solid@ h3 = translate (x+wall-hr,hr+wall,-wall)*cylinder(20,r);
   solid@ h4 = translate (x-hr+wall,y-hr+wall,-wall)*cylinder(20,r);
return translate (-wall,-wall,-wall)*(topall - h1 - h2 - h3 - h4);
 
 
    }
   
solid@ sup()    //support for pcb and screw holes for lid (standoff)
{
   solid@ block= cylinder(soh,sod/2,true)-cylinder(soh,shole/2,true);
   return translate(0,0,soh/2)*block;
}
 
solid@ standoffs()    // add standoffs
{
   array<solid@> p;
   for (int j=0;j<son;j++)
      {
      p.push_back( translate(stands[j].x(),stands[j].y(),0)*sup());
      }
return union3d(p);
}
 
solid@ holes()    // number of ventilation holes in each direction
{
   int nx= int((x3-x1)/space) ;
   int ny= int((y3-y1)/space) ;
   double dx=space;
   double dy=space;
   // create an array of cuboids a grid pattern in 1st quadrant
   array<solid@> h;
   for (int ix=0;ix<=nx;ix++)
   {
      for (int iy=0;iy<=ny;iy++)
      {
         double xh = x1 + ix*space;
         double yh = y1 + iy*space;
       h.push_back(translate(xh,yh,0)*cuboid(hole,hole,100,true));
      }
   }
   // return the cylinders as a single solid
return union3d(h);   
}

solid@ fix()     // fix standoffs at top corners for screws for lid
{
   double hr =shole/2;
   solid@ h1 = translate (hr,hr,z-soh)*sup();
   solid@ h2 = translate (hr,y-hr,z-soh)*sup();
   solid@ h3 = translate (x-hr,hr,z-soh)*sup();
   solid@ h4 = translate (x-hr,y-hr,z-soh)* sup();
return h1 + h2 + h3 + h4;
}
 
solid@ boxholed()  //add ventilation holes to box if required
{
   if (boxhole == true)
      {     
      return box() - holes();
      }
return box();
}
           
solid@ lidholed()  //add ventilation holes to lid if required
{
   if (lidhole == true)
     {
      return lid() -holes();
      }
return lid();     
}
     
void main()    //put all the parts together
{
   solid@ both=boxholed()+translate(0,y+3+wall+wall,0)*lidholed() +fix()+standoffs();
   both.write_xcsg(GetInputFullPath(),secant_tolerance:-1.0);
}

edited the above code to correctly offset resized rounded corner lid part - hopefully fits now!
7
Using AngelCAD / Re: AngelCAD on Thingiverse
« Last post by Carsten Arnholm on 2020-06-10, 09:18:01 »
I designed a new wall adapter using AngelCAD for the TP-link Deco M9+ mesh router
See https://www.thingiverse.com/thing:4441436

The AngelCAD source code for this adapter model is available there too.
8
Hi, after a quick review I think the problem is trying to union tubular shapes with same radius, but not identical mesh representations at the ends where the circular shapes meet. This sometimes works, sometimes not. For example, this kind of works

Code: [Select]
shape@ main_shape()
{
   // scale down for web visualisation
   return circle_bottom()+ mirror(1,0,0)*circle_top();
}

See attached image.

But the result is not perfect because the intersection between the two shapes edges don't line up at the ends. All the boolean operations are mesh based, so everything is discretized into meshes with triangular faces and straight edges. For circular cross sections like in this case you may end up with different discretizations that don't always result in a useful result after a boolean operation. In this case you get the "Warning: Polyhedron is not water-tight" message for this reason. If you don't do the mirror the problem is more severe (because tubes with same radus/different discretization meet "everywhere") and you might end up with losing parts as you saw.

One possible remedy is to create a "junction cylinder" with slightly larger radius so that the other shapes meet a flat surface, causing fewer problems with non-aligning edges. Perhaps this is acceptable for your use, perhaps not.

In essence I think this is what you are seeing.

9
Hi Carsten. the result is not going to look like this, but it is interesting for an analysis I have in modeling of an optical cable.
Optical cables have loss when being bent to much and I will use this to find best case e.g bend radius on optical cables.

I have time to wait, and I think the answer you come up with would be very interesting for other solids, as well as for debugging issues later.
Thanks for your effort
10
Hello, interesting example. Is this for some real life modelling, or just "random testing"? I will need a bit of time to study it before coming back with more specific answers, please allow for that.

In general, the polyhedron warning can be a real issue or sometimes kind of false alarm. A polyhedron with 8 edges, all with use count 1 sounds like a couple of loose faces, so possibly a real issue.

In general, you want solids to slightly overlap each other, i.e. not "exact" face/face intersections as that can be ambiguous. This sort of thing can sometimes be a little tricky to get right.  As noted, I will try your code later.
Pages: [1] 2 3 4