skymakerolof / dxf

DXF parser for node/browser
https://www.npmjs.com/package/dxf
MIT License
335 stars 122 forks source link

Hatch with polyline points only returning y coordinate #130

Closed mstigter0 closed 1 year ago

mstigter0 commented 1 year ago

Hi,

I've got an issue with parsing hatches with polyline points (only y values are returned). image

I've found that removing the Object.create() and just setting polypoints to the object fixes my issue but i dont know if this creates other issues. I saw that this line was added in a commit that added the bulge to the polypoints (879808c). https://github.com/skymakerolof/dxf/blob/72302c5ca3e62721b805725aad105eb7f12b4d2e/src/handlers/entity/hatch.js#L30-L34 image

I cant see why Object.create(0 doesnt work so would appriciate it if this is looked at.

Akbar1909 commented 1 year ago

The same result on my side

stevage commented 1 year ago

Yes, I found the same thing. And the fix suggested works for me.

I'm not sure why Object.create() is used here (and in a few other places) but it definitely looks wrong. I think what is happening is:

  1. polyPoint is initialised with a value of {} (and a prototype that includes values for x, y and bulge)
  2. polyPoint.y is given a value
  3. ...that's it. So when polyPoint (now inside an array) is returned later on, it has just a y property.