Author Topic: Convert2PDF Update  (Read 3339 times)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3511
    • View Profile
    • T2Laser
Re: Convert2PDF Update
« Reply #30 on: September 06, 2016, 08:46:36 AM »
I did notice some of the shapes do not completely join, is that a problem?

I have a setting to auto-join if they are within a user defined tolerance but some were larger than what I had set (the front tip of the elevator for example).

Administrator

  • Administrator
  • Hero Member
  • *****
  • Posts: 1934
  • Pilot Instructor
    • View Profile
Re: Convert2PDF Update
« Reply #31 on: September 06, 2016, 09:00:42 AM »
Attached is a zoom-in on the front of the elevator. Is that what you mean?

I seem to recall from my airplane model building days that this kind of gap on an elevator is done on purpose (?).

In any event, this can be 'fixed' in BCL (if its determined that it needs to be fixed) by grouping the elevator Line and Spline objects together using the TC/IC/LC tags.

But this gap I believe (let's say it is a CAD mistake and should not be there) is too big to 'connect over' and join up as a group. While BCL can do that, my suggestion in this case would be to go back into the CAD program and just fix it. Again, we're assuming the gap is a mistake, but I don't think it is.
Ralph--Admin -- support_BenCutLaser_us
http://www.BenCutLaser.us/BenCutLaserSetup1.8.3a.exe.zip
http://www.BenCutLaser.us/BCLVirtualLaserMachineSetup1.8.2.exe.zip
BCL Paid license: $39.95
VLM Paid license: $19.95 (stand alone version)
via Paypal to bclpp@primemail.com

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #32 on: September 06, 2016, 09:09:44 AM »
Thanks Zax for checking those in T2Laser! I need to start checking them in T2 as well but so far I've just been using BCL and DWG TrueView to test with. And, if Ralph keeps coming out with more updates I shouldn't hit the startup limit lol.

All of the files I've converted so far, where I didn't convert the lines and splines to any other objects will load in Autocad DWG TrueView and BCL which are the two programs I use to test with right now. The converted files will load in TrueView but not all of them will load into BCL. I suspect this might be due to how LwPolylines are read in BCL but that's only a guess. When a file fails to load in BCL it says index was out of the bounds of the array. If my suspicions are correct I think I have a solution for this.

The Arc and Circle converter still has a couple bugs in it as well but is nearly complete. Believe it or not, the trickiest part was not the arcs or circles, it was the lines lol.

From the PDF reference guide...
Quote
A path is composed of straight and curved line segments, which may connect to
one another or may be disconnected. A pair of segments are said to connect only
if they are defined consecutively, with the second segment starting where the first
one ends. Thus the order in which the segments of a path are defined is signifi-
cant. Nonconsecutive segments that meet or intersect fortuitously are not considered
to connect.

This became apparent with one of my test files.

Within a path, you have sub paths and the sub paths have line or curves and they can be mixed. The problem comes in when you have 3 sides of a rectangle in one sub path and the other side in a separate sub path. The shapes inside a sub path are connected but sub paths are not considered connected to each other.

To convert these to LwPolylines, instead of lines, I have two options. 1. just convert the connected lines in the one sup path and draw the remaining line as a simple line, or 2. Take all of the lines for a single path and all of its sub paths, and apply some logic to find all of the lines that connect to each other. I went with option 2 because a lot of PDFs will have come from some converter  which may or may not preserve the shapes the same as they were. Inkscape has shown this to be true and I imagine others will do the same.

I know this seems like a lot of fuss for nothing but I'd like to have the option to let the converter do most of the work for me so that I don't have as much work to do when I get into BCL. Obviously this is not an issue for T2 since it doesn't matter to T2 if it is made up of just lines and splines.


Ok, so do you guys want to wait for the text, paths, and images to all be coded or would you guys prefer to do a phased test approach? I can wrap up the path import code and give you guys the dll libraries to test just that or wait until I have text, paths, and images all coded up and then deliver all of that at once.

Thanks
John

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #33 on: September 06, 2016, 09:21:29 AM »
Attached is a zoom-in on the front of the elevator. Is that what you mean?

I seem to recall from my airplane model building days that this kind of gap on an elevator is done on purpose (?).

In any event, this can be 'fixed' in BCL (if its determined that it needs to be fixed) by grouping the elevator Line and Spline objects together using the TC/IC/LC tags.

But this gap I believe (let's say it is a CAD mistake and should not be there) is too big to 'connect over' and join up as a group. While BCL can do that, my suggestion in this case would be to go back into the CAD program and just fix it. Again, we're assuming the gap is a mistake, but I don't think it is.

It is that way in the original PDF too and I believe this was done this way so that the parts would stay in the sheet of foam board when they pulled it out of the laser cutter. When you would get the laser cut sheets from them, you would just take a box cutter and cut the holding tabs and remove the part.

Administrator

  • Administrator
  • Hero Member
  • *****
  • Posts: 1934
  • Pilot Instructor
    • View Profile
Re: Convert2PDF Update
« Reply #34 on: September 06, 2016, 09:23:51 AM »
I like a phased approach so I can start testing it sooner rather than later -- BUT -- that is up to you John. If you'd prefer to wait, then I'm fine with that too.

>When a file fails to load in BCL it says index was out of the bounds of the array.

This could be a bug in BCL...when this happens please email me the file and let me have a look at it. I may need to add some code to provide a more graceful error recovery than an index out of bounds error.

Thanks...
Ralph--Admin -- support_BenCutLaser_us
http://www.BenCutLaser.us/BenCutLaserSetup1.8.3a.exe.zip
http://www.BenCutLaser.us/BCLVirtualLaserMachineSetup1.8.2.exe.zip
BCL Paid license: $39.95
VLM Paid license: $19.95 (stand alone version)
via Paypal to bclpp@primemail.com

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #35 on: September 06, 2016, 09:24:28 AM »
These all loaded into BCL without any problems...!!!

I can tell you, I could laser these 4 drawings absolutely perfectly!

The elevator is beautiful...if the rest of the plane drawings come out this perfect...we are in business building airplanes...!!!

Beautiful work, absolutely beautiful...job well done...!!!

Thanks Ralph for the kind words :)

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #36 on: September 06, 2016, 09:27:51 AM »
I like a phased approach so I can start testing it sooner rather than later -- BUT -- that is up to you John. If you'd prefer to wait, then I'm fine with that too.

>When a file fails to load in BCL it says index was out of the bounds of the array.

This could be a bug in BCL...when this happens please email me the file and let me have a look at it. I may need to add some code to provide a more graceful error recovery than an index out of bounds error.

Thanks...

lol, I just assumed it was something I was doing wrong but yeah, I know what you mean about getting those error messages. I'll send the file tonight when I get home and maybe you can confirm my suspicions.

I like the phased approach too. This way we can all sign off on each piece working before we tackle the next part.

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3511
    • View Profile
    • T2Laser
Re: Convert2PDF Update
« Reply #37 on: September 06, 2016, 10:00:18 AM »
Phased approach works for me too, but I really think BCL is the right validation. If it works with T2Laser that's just a bonus for users that do mainly engraving but occasionally need to import vectors.

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #38 on: September 06, 2016, 12:01:18 PM »
lol, I need it to work with both! In fact, I should probably call that option BCLmode or T2LaserMode lol, kidding of course. Yeah, I knew T2Laser could handle the lines and splines so once I got that working and since that is the basic needs for PDF paths, I've just been focusing on the converted stuff.

The option is there to turn the converting feature on or off. The other options are Millimeters or Inches for the DXF output, One method for just passing in a file name/path and having it save to disk, and the other method returns a MemoryStream of the DXF file. If you guys need or want something else just let me know. I'm sure the options will grow as this progresses but that's what I have for now.

Administrator

  • Administrator
  • Hero Member
  • *****
  • Posts: 1934
  • Pilot Instructor
    • View Profile
Re: Convert2PDF Update
« Reply #39 on: September 06, 2016, 12:57:48 PM »
Actually, your naming idea is perfect: BCLMode or T2Mode.

I'd prefer your converter write the .dxf file to disk. Then BCL can just load it in as usual. I think that's the cleanest solution, but let's hear what @Zax has to say! Maybe you can offer both ways?
Ralph--Admin -- support_BenCutLaser_us
http://www.BenCutLaser.us/BenCutLaserSetup1.8.3a.exe.zip
http://www.BenCutLaser.us/BCLVirtualLaserMachineSetup1.8.2.exe.zip
BCL Paid license: $39.95
VLM Paid license: $19.95 (stand alone version)
via Paypal to bclpp@primemail.com

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3511
    • View Profile
    • T2Laser
Re: Convert2PDF Update
« Reply #40 on: September 06, 2016, 01:43:00 PM »
Since I have no idea how to implement the "stream" it sounds better to save the DXF.

I think I support the same shapes as BCL except text, in mm or inches. I could add text, I'm sure it isn't too difficult. That may simplify things.

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #41 on: September 06, 2016, 02:46:17 PM »
I didn't know what you guys would need so I just made both options available. It really depends on what you use to read in DXF files. If you don't have an option to use a stream instead of a file path, then your only option would be to save it to disk and then load it in. Both options are there, its completely up to you which you want to use. :)

Just for kick and giggles...
For example (in VB) if you wanted to read a text file...
Quote
VB.NET

'You first get a stream for the text file
Dim fs As FileStream = New FileStream(path, FileMode.Open) <-- this step can be skipped if you already have a stream object.

'Then you can read the stream
Dim sr As StreamReader = New StreamReader(fs) '<-- start here if you already have a stream object.

'Now you can do something with it.
Do While sr.Peek() >= 0
   Console.WriteLine(sr.ReadLine())
Loop
sr.Close()
fs.Close()

same thing in c#
Quote
//You first get a stream for the text file
using (FileStream fs = new FileStream(path, FileMode.Open))
{
    //Then you can read the stream
    using (StreamReader sr = new StreamReader(fs)) //<-- start here if you already have a stream object.
    {
        //Now you can do something with it.
        while (sr.Peek() >= 0)
        {
            Console.WriteLine(sr.ReadLine());
        }
    }
}

ok, I'll create an enum with BCLMode (ok, I'll cap the M lol) and T2Mode and you can just pick which "Mode" you want.

Unless you need something else, the options I already have available are...
1. The path for the PDF file to convert.
2. The path where to save the DXF file.
3. If you want the DXF file saved in MM or IN
4. And last but not least... BCLMode or T2Mode (which basically just means convert or don't convert the paths)

We can add other options like to include or exclude text and images when converting to DXF as we add that other functionality.
« Last Edit: September 06, 2016, 02:47:08 PM by Agastar »

Administrator

  • Administrator
  • Hero Member
  • *****
  • Posts: 1934
  • Pilot Instructor
    • View Profile
Re: Convert2PDF Update
« Reply #42 on: September 06, 2016, 02:51:04 PM »
Will your converter be usable by someone who wants to manually convert a pdf into a dxf file? Or is your converter only going to be a dll file that BCL and T2 can use?
Ralph--Admin -- support_BenCutLaser_us
http://www.BenCutLaser.us/BenCutLaserSetup1.8.3a.exe.zip
http://www.BenCutLaser.us/BCLVirtualLaserMachineSetup1.8.2.exe.zip
BCL Paid license: $39.95
VLM Paid license: $19.95 (stand alone version)
via Paypal to bclpp@primemail.com

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #43 on: September 06, 2016, 03:06:43 PM »
Right now my VS solution has a console app that I use for testing but I'm looking at adding a WPF app to load and view the PDF with some basic options like selecting what from the PDF you want to export to DXF.

Currently I use Inkscape to chop up the PDF and save to another PDF. I'll post the workflow for that too. The WPF app will come after all the other features are implemented. I've been looking at adding a simple app for my testing purposes so I might have something basic soon.

Agastar

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1878
    • View Profile
Re: Convert2PDF Update
« Reply #44 on: September 06, 2016, 11:47:34 PM »
ok, so I got a little brave tonight and had a go at the full FT-3D-plans.pdf and this time I started with the original as I downloaded it from FT's website. Before I was loading it into Inkscape, chopping it up, saving that as a PDF and then converting it.

Ok, maybe I wasn't that brave because I turned off the shape converting for this run lol.

I am attaching the original PDF and the two pages it created in DXF format.

Warning, these don't load in BCL.

That's ok because I would not really try this for a real run. What I would do is load the PDF into Inkscape and remove all the stuff I didn't want like pictures and other graphics, fix any little gaps, and definitely, for my little machine I would need to split it up.

I'm going to finish cleaning these up and splitting them into workable sections and then I'll post the full set of DXF files for here for anyone who wants them.

So far line converting is all done, now there is just one last arc bug I have to work out and we should be good for converting paths.

well, the PDF is too large to post so here is the link.
http://www.stonekap.net/ftplans/FT-3D-plans.pdf