Drawing a dxf cylinder

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

Post Reply
XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Drawing a dxf cylinder

Post by XxOsurfer3xX » Thu May 15, 2014 11:00 am

I have a cylinder in parametric form, that I want to draw as a dxf. What would be the optimal way of doing this with dxflib? Using polygons? NURBS? I am new to AutoCAD and not sure about the ways I can do this. I tried creating a cylinder in AutoCAD 2014 and exporting it to DXF and it only creates two circles, with the base and top part of the cylinder. Also, it looks like it cannot be rotated...

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Drawing a dxf cylinder

Post by andrew » Mon May 19, 2014 9:25 am

dxflib is mostly suitable for 2D content. We use it for the free community edition of QCAD (also 2D).
3D content might be achievable using extrusion. Please note that not every viewer / CAD system supports these. QCAD being 2D doesn't.

XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Re: Drawing a dxf cylinder

Post by XxOsurfer3xX » Mon May 19, 2014 11:21 am

Thanks a lot for your anwser andrew. So are you saying that dxflib is not capable of achieving what I want or that the result will not be compatible with every viewer? I am OK with the second, I don't need full compatibility. If indeed would be possible to use extrusion with dxflib, could you point me in the right direction, so I can try to experiment a little bit (what entities I need to use, etc.)?

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Drawing a dxf cylinder

Post by andrew » Mon May 19, 2014 11:37 am

dxflib does currently not support writing extrusions. Support could be added relatively easily in DL_Writer::entityAttributes.

Note that even if you have extrusion support, you won't be able to create a cylinder that is rotated in 3D space (extrusions are parallel to the X/Y plane).

XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Re: Drawing a dxf cylinder

Post by XxOsurfer3xX » Mon May 19, 2014 11:49 am

I would not mind adding extrusions myself and contributing to the project, but I would need to be able to rotate the resulting primitive. Can this be achieved using dxf?

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Drawing a dxf cylinder

Post by andrew » Mon May 19, 2014 11:58 am

XxOsurfer3xX wrote:Can this be achieved using dxf?
Not 100% sure, but I think you'd have to use a 3DSOLID entity to represent such a body.
3DSOLID entities are available in DXF but consist of proprietary, binary, undocumented data.

I'd recommend to find a 3D CAD application, create the type of cylinder you need, export it to DXF and cross-check the result with a 3D DXF viewer. The DXF file reveals what entity can be used best to represent such a body.

XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Re: Drawing a dxf cylinder

Post by XxOsurfer3xX » Mon May 19, 2014 12:11 pm

I have been looking at DXF documentation and in the circle entity I can see:

210

Extrusion direction (optional; default = 0, 0, 1)
DXF: X value; APP: 3D vector

220, 230

DXF: Y and Z values of extrusion direction (optional)

Wouldn't that let me extrude in any direction I want?

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Drawing a dxf cylinder

Post by andrew » Mon May 19, 2014 12:15 pm

XxOsurfer3xX wrote:Wouldn't that let me extrude in any direction I want?
You'd have to try it:
Export a circle to DXF
Add the extrusion vector manually
Load the resulting DXF file in a 3D viewer

XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Re: Drawing a dxf cylinder

Post by XxOsurfer3xX » Mon May 19, 2014 12:20 pm

Ok, I'll go ahead and try. I'll keep you updated with the results. Thanks a lot for your help.

XxOsurfer3xX
Newbie Member
Posts: 6
Joined: Thu May 15, 2014 10:49 am

Re: Drawing a dxf cylinder

Post by XxOsurfer3xX » Thu May 22, 2014 8:53 am

I can confirm it is possible to create a 3D cylinder extruding a circle, using extrusion direction and thickness. The main problem is that when using a extrusion direction different from the default one (0,0,1), the object appears in different coordinates, as if the UCS was changed... Anyone knows why can this be happening? In the upcoming weeks I'll try to make it work with dxflib, and see what happens...

Post Reply

Return to “dxflib 'How Do I' Questions”