# Drawing a dxf cylinder

**URL:** <http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587>\
**Category:** dxflib 'How Do I' Questions\
**Created:** [May 15, 2014, 10:00am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587 "2014-05-15T10:00:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 15, 2014, 10:00am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/1 "2014-05-15T10:00:52Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![andrew](http://forum.qcad.org/user_avatar/forum.qcad.org/andrew/32/15013_2.png) [@andrew](http://forum.qcad.org/u/andrew)\
**Post date:** [May 19, 2014, 8:25am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/2 "2014-05-19T08:25:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 19, 2014, 10:21am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/3 "2014-05-19T10:21:30Z")

</div>

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.)?

---

<div class="post-metadata">

**Author:** ![andrew](http://forum.qcad.org/user_avatar/forum.qcad.org/andrew/32/15013_2.png) [@andrew](http://forum.qcad.org/u/andrew)\
**Post date:** [May 19, 2014, 10:37am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/4 "2014-05-19T10:37:38Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 19, 2014, 10:49am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/5 "2014-05-19T10:49:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![andrew](http://forum.qcad.org/user_avatar/forum.qcad.org/andrew/32/15013_2.png) [@andrew](http://forum.qcad.org/u/andrew)\
**Post date:** [May 19, 2014, 10:58am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/6 "2014-05-19T10:58:54Z")

</div>

> [@XxOsurfer3xX](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 19, 2014, 11:11am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/7 "2014-05-19T11:11:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![andrew](http://forum.qcad.org/user_avatar/forum.qcad.org/andrew/32/15013_2.png) [@andrew](http://forum.qcad.org/u/andrew)\
**Post date:** [May 19, 2014, 11:15am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/8 "2014-05-19T11:15:45Z")

</div>

> [@XxOsurfer3xX](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 19, 2014, 11:20am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/9 "2014-05-19T11:20:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![XxOsurfer3xX](http://forum.qcad.org/letter_avatar_proxy/v4/letter/x/f07891/32.png) [@XxOsurfer3xX](http://forum.qcad.org/u/XxOsurfer3xX)\
**Post date:** [May 22, 2014, 7:53am UTC](http://forum.qcad.org/t/drawing-a-dxf-cylinder/1587/10 "2014-05-22T07:53:49Z")

</div>

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…
