I want to get a xyz points of 3d objects written in .dxf, .stl to make my 3d printer software.
I tried python dxf parser, but It couldn't get xyz cordinates of 3d objects.
Anyone smart to know how can I do this?
I want to get a xyz points of 3d objects written in .dxf, .stl to make my 3d printer software.
I tried python dxf parser, but It couldn't get xyz cordinates of 3d objects.
Anyone smart to know how can I do this?
3D objects are encoded using binary data in a DXF file (similar to the output obtained when selecting a 3D object after evaluating the AutoLISP expression (entget (car (entsel)))
at the AutoCAD command-line); you will therefore not be able to obtain the information you require by reading the DXF file as plain text.
Since very few properties of 3D objects are exposed to the LISP API in AutoCAD, I would suggest that you interrogate the properties of the object using .NET - there are many resources online describing how this may be achieved.
I would use MeshLab, this an open source app which can read an STL file and export an XYZ Point Cloud text file with or without normal information. Each vertex will appear as three floating point values separated by a space, EG (without normal data);
-90.936005 122.486008 4.072000
-95.642006 139.926010 4.072000
-96.862007 139.952011 4.072000
and with normal data;
-90.936005 122.486008 4.072000 0.000000 0.000000 0.078929
-95.642006 139.926010 4.072000 0.000000 0.000000 0.099790
-96.862007 139.952011 4.072000 0.000000 0.000000 1.148707
You could then use standard Python I/O to access the data in the text file.
Though, if you are happy to work with facets then you just need to access an ASCII form of the STL file where the text file has a sequence of facet records such as;
facet normal -0.000000e+000 0.000000e+000 1.000000e+000
outer loop
vertex -3.315800e+001 1.389420e+002 4.072000e+000
vertex -3.104200e+001 1.389120e+002 4.072000e+000
vertex -3.111600e+001 1.389960e+002 4.072000e+000
endloop
endfacet
...
endsolid vcg
You could use MeshLab to convert between binary and ACSII STL files.