3

I am parsing a DXF (Autocad) file. In this file there are several entities with an extrusion vector different from the "default" (0, 0, 1). I am having a lot of trouble parsing these entities because their coordinates have to be mapped in order to be represented in a 2D plane.

So, if for example I have a line entity with the following properties:

x1 = 10
y1 = 10
x2 = 20
y2 = 30

And with an extrusion vector of (-0.1, 0.1, 0.5) what will be the real line coordinates once it is representes in a 2D plane?

Nick
  • 10,309
  • 21
  • 97
  • 201

1 Answers1

1

A line is a 3D entity. Start and end point coordinates are in the World Coordinate System (WCS). Extrusion vector does not have an impact here, it's only for 2D entities like circle, arc, ellipse and 2D polylines for example.

Maxence
  • 12,868
  • 5
  • 57
  • 69
  • Ok, so what I have to do for 2D entities like the ones you cited? – Nick Aug 28 '15 at 10:03
  • 2
    You have to project points on the plane which normal is the extrusion vector and origin is the origin of the WCS. To project point, you can use dot and cross products like described in this answer: http://stackoverflow.com/a/9605695/200443. In fact, it's Object Coordinate System (OCS) to WCS transformation. – Maxence Aug 28 '15 at 10:09
  • Read this about OCS: http://www.autodesk.com/techpubs/autocad/acadr14/dxf/object_coordinate_systems_40ocs41_al_u05_c.htm – Maxence Aug 28 '15 at 10:13
  • Don't forget to take elevation in account – Maxence Aug 28 '15 at 10:16
  • I am still confused, can you make me an example by using any of the 2D entities? – Nick Aug 28 '15 at 12:21
  • I'm afraid I've don't have time to write this kind of example. You need to first have a vector class at least for this. Maybe this [post](http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-trans-wcs-to-ocs/m-p/1131870#M161066) can help. – Maxence Aug 28 '15 at 12:41