Message Boards Message Boards

Export a 3D graphics in dxf or stl not converted in triangles?


I need to export in dxf or stl format some 3D geometrical constructions I made in Mathematica. But when the exported files are examined in a CAD viewer I see only figures formed out of triangles. Sometimes some triangles appear in unexpected places. Here is an example.

tube = {CapForm[None], Tube[{{0, 0, 0}, {0, 0, 10}}, 5]};
cube = Cuboid[{10, 10, 0}, {20, 20, 10}];
G3D = Graphics3D[{tube, cube}];
Export["G3D.dxf", G3D];

The circle of the tube is decomposed into a polygon and the tube's surface is decomposed into rectangles and the rectangles into triangles. The cube looks better but I do not want it to be made out of triangles but out of rectangles.

POSTED BY: Petre Logofatu
2 months ago

enter image description here

Hello Petre,

sorry for this late response - hopefully it is still a bit helpful though! I would rather treat these graphics seperately. Furthermore please notice that I added a certain thickness to the tube. Obviously the conversion to a BoundaryMeshRegion does the trick:


cube = Cuboid[{10, 10, 0}, {20, 20, 10}];
cubeBoundaryMesh = BoundaryDiscretizeRegion[cube]

Export["cube.stl", cubeBoundaryMesh]

tube = SolidData[Entity["Solid", "CylindricalShell"], "Region"][2.5, 2.4, 5];
tubeBoundaryMesh = BoundaryDiscretizeRegion[tube, MaxCellMeasure -> {"Length" -> .1}]

Export["tube.stl", tubeBoundaryMesh]

Regards -- Henrik

POSTED BY: Henrik Schachner
2 months ago

Thank you for your help, I appreciate it. However it does not seem to work with my Mathematica version (10). There are now problems even with the Mathematica graphic representation and it also says it cannot export BoundaryMeshRegion to the stl format. Is there a way to set certain values for the dimensions of the figures? Someone who read my dxf and stl files with a CAD program said it shows dimensions of hundred of meters. They should be in the order of millimeters or even micrometers.

POSTED BY: Petre Logofatu
2 months ago

STL does not support any units, the number in graphics are just converted to numbers. So these numbers can be interpreted as kilometers, meters, millimeters, lightyears, Plancklengths et cetera... Either you scale them in e.g. millimeters (what is commonly used in CAD), or tell the CAD software that the number it reads should be interpreted as e.g. millimeters...

You can use Scale to scale everything:

Scale[Sphere[{0.5, 0.5, 0.5}, 0.050], 1000, {0, 0, 0}]  (* all units in meters, then converted to millimeter *)
Graphics3D[%, Boxed -> True, Axes -> True]
Export["out.stl", %]
Show[Import["out.stl"], Boxed -> True, Axes -> True]

Shows that the STL file indeed is now scaled to millimeters

POSTED BY: Sander Huisman
2 months ago

Group Abstract Group Abstract