DeepNestSharp icon indicating copy to clipboard operation
DeepNestSharp copied to clipboard

Casting LWPolylines to DxfPolylines in IxMilia

Open westwinnd opened this issue 1 year ago • 5 comments

Now, it will be complicated, i'm not used to write issues, so please be patient, I will elaborate it. Issue is coneccted to feel88 DeepNestPort and 9swampy DeepNestPort repositories, they all have same problem with export.

NOW I am aware that in DeepNestSharp (current one, this repository) exception is handled, that is why I mention both upper ones, but with context, I was able to dig into problem deeper.

  1. Runtime Exception text: (from author feel-88 and 9swampy DeepNestPort)

(Bold text in block of this text translated by me, unnecessary paths removed)

System.InvalidCastException: **You can't cast object of type** 'IxMilia.Dxf.Entities.DxfLwPolyline' **to type** 'IxMilia.Dxf.Entities.DxfPolyline'.
   w DeepNestLib.DxfParser.OffsetToNest(IList`1 dxfEntities, DxfPoint pivot, DxfPoint offset, Double rotationAngle) in [...]\DeepNestPort-master\Framework\DeepNestLib\DxfParser.cs:line 362
   w DeepNestLib.DxfParser.Export(String path, IEnumerable`1 polygons, IEnumerable`1 sheets) w [...]\DeepNestPort-master\Framework\DeepNestLib\DxfParser.cs:line 217
   w DeepNestPort.Form1.toolStripButton2_Click_1(Object sender, EventArgs e) in [...]\DeepNestPort-master\Framework\DeepNestPort\Form1.cs:line 1360

Now, in this repo there is added DxfExporter.cs, in DeepNestLib.Core, probably to solve problem, to substract and differ input and output. I tested it myself and found a reason, in a moment function OffsetToNest( receives LwPolyline object it cannot cast it to DxfPolyline, so maybe it should get this type at export.

I "solved" it temporaly by removing case LwPolyline in OffsetToNest function, cause this needs to be resolved by writing external module outside IxMillia lib,, which perform the cast (you cannot offset LWPolyline vertices), or by externing IxMilia by yourself.

Or I am blind, and don't see some easy solution, hah.

westwinnd avatar Jul 18 '24 16:07 westwinnd

@fel88 forwarded, to information.

westwinnd avatar Jul 18 '24 21:07 westwinnd

@fel88 forwarded, to information.

Hi! Can you provide the dxf file you are trying to load?

fel88 avatar Jul 19 '24 16:07 fel88

FAKEPARTS.zip @fel88

westwinnd avatar Jul 22 '24 17:07 westwinnd

I've tried to nest you parts, and I've not faced any errors or exceptions. It seems works well. The resulting files (sheet1.dxf, sheet2.dxf) can be opened in LibreCAD without any problems. So, could you please be more specific how to reproduce the exception you mentioned before? Maybe you can provide particular STR (steps to reproduce) or a video? nests.zip

fel88 avatar Jul 22 '24 19:07 fel88

yes, I will try reproduce it in this week and feed a result to you!

westwinnd avatar Jul 31 '24 13:07 westwinnd