How to handle pdf import properly and feasibly?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Thu Mar 20, 2014 8:08 pm

Hi,
I would like to present you my provisional wire-snap-trace work flow solution for today:
I do it mainly in inkscape. On a further layer I snap-draw a close polyline and then save only that layer to dxf-R14 or svg
This I import in freecad, measure it: If decimal point is not at right place, than change in inkscape Object/Transform/Dimensions
and once again import it. Thats all. Its a compromise solution, if all others ways are - failing, what they usually do - for firsttimer.

Comments?
tia.

PS: Will read the posts in the meanwhile later and answer.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Fri Mar 21, 2014 3:26 pm

wow. :o
I resume:
-you deleted "clutter"
-reduced the number of items from around 15000 to about 400
-you could quantify them and analyse the situation
-you could determine which of them were relevant
-reduced file size factor ten
- you did it wihtin inkscape.
- the result is ok

So questions:
With which -tools, -skill, -work flow does one acchieve the above?.
2. questions:
Could you enlight me, on what does it depend, that it comes to that?

tia





jmaustpc wrote:The SVG file is horrible...it is so full of clutter, its no wonder it takes forever to import and causes you problems.

I have deleted all the brick work and soil and dimensions, as they were all individual svg paths. There were thousands of them. There is still more clutter you could delete.

I opened it in Inkscape, deleted all the clutter, then ether import in FreeCAD as SVG geometry or first in Inkscape save as DXF and then import the DXF into FreeCAD.

Then you don't have to trace a bit map you just have the geometry already as though you had traced it.
h_declutter2.fcstd
h_declutter2.dxf
h_declutter2.svg
Jim

OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3342 (Git)
Branch: master
Hash: ca6d37202593752c0eeeb1ce56cb4d8c3baf27c0
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
jmaustpc
Posts: 9638
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to handle pdf import properly and feasibly?

Postby jmaustpc » Fri Mar 21, 2014 4:07 pm

It depends greatly on what the content of the PDF actually is. They can have vector graphics or bit map or both. They can have file attachments as well. In that sense they are a bit like a container of "stuff" and some instructions on how to display it.

So your method would vary depending on the individual pdf file.

This is the pdf page on wikipedia
http://en.wikipedia.org/wiki/Portable_D ... l_overview

I opened the svg file you posted in Inkscape and saved a copy then used the default "box select tool" to select and delete all the clutter. The default behaviour of "box select" in Inkscape is that is will only select items fully contained within the box, which makes it easy to for example delete all the paths of the bricks in the chimney by drawing a box that was just shorter than the outer edge paths.

The SVG I posted had most of the clutter removed but still needed work. I also did not resolve the scaling or sizing of all the components once imported into FreeCAD.


If you have a bitmap image, you can go to the FreeCAD image wb and display it in an image plane and then model over the image using it as a visual guide. But you can not use FreeCAD's snapping function on the bitmap image in the image plane.

Mario posted a script that converts bitmaps into FreeCAD items ...but I know nothing at all about how it works or what it does or if it would help you in your specific case or not. You would have to try it and/or ask him. :)

In each specific case I would suggest that you also look at a bitmap and decide if it is worth all the effort trying to convert and import it or if it might be quicker and better to just read the data from it and re-create the model by hand in FreeCAD.

Jim
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Sat Mar 22, 2014 12:54 pm

@ mario: interesting, gonna check it, when I soon have to treat a scanned plan.
Is not it a recognition method (color, edge?) and does inkscape not provide as well tool for "vektorizing", I ask myself?
@Jim
it is sometimes a little tedious, e.g. the side view with much bricks. Then one could choose drawing and exporting just a polyline in another layer. Even for inkscape the performance impact is quite notable.
As far as ground plans are concerned I found, that for me, who need mainly the contours, one use
comfortably shift left-mouse-drag. - No so much shift alt leftmouse-drag.
With one selection one wipes out the whole interiour.
http://tavmjong.free.fr/INKSCAPE/MANUAL ... lect-Mouse

Thank you for the interest and for the valuable help!
mario52
Posts: 2921
Joined: Wed May 16, 2012 2:13 pm

Re: How to handle pdf import properly and feasibly?

Postby mario52 » Sat Mar 22, 2014 2:13 pm

hi
Vectorise a BMP image with FreeCAD and FCTexture is very very easy :

Procedure 1: create an image.BMP 32 bits for your project
Import the image in Gimp
Compose your image as just as possible (to decrease the processing time)
Create a layer with a transparent background and activate the layer
Point all the benchmarks with a different color for each object to not get lost with the points
The color chosen for the points must be in result below 255,255,255 (white) ex: max 250,250,250
Then back color of your layer in white (255,255,255)
Hide the original page and save the format layer .BMP mode 32 bit colors

Procedure 2: Calculate the raport of scale
*Home of the plan height = 6000 mm
*The House in the bmp image = 224 pixels image height = 224 mm
*rapport = 6000/224 = 26,78571428

Procedure 3: In FreeCAD
Open FCTexture and in :
*Stretching X type 26,78571428
*Stretching Y type 26,78571428
Enable outlining mode (Raw mode is automatically set to 255 and do not touch anything)
Open a page in FreeCAD
Click "File and launch" and select your file .BMP and . . .
*Treatment with FCTexture with an image of 837px x 262 px and 372 points: Time: 0.53 min
*

Draw and connect the points with millimetric precision.
Delete the points (if needed)

After a few tries you will forget SVG format !

EDIT : 28/03/2014 22:15 , removing image provided by teobo, Copyright is unknown and replacement by an image on the wiki of FreeCAD Arch_tutorial and designed by Yorik

PS: the image is high the result is accurate
Arch_tutorial_51.jpg
Arch_tutorial_51 (designed by Yorik)
Arch_tutorial_51.jpg (98.34 KiB) Viewed 2923 times
Arch_tutorial_51_01.png
Arch_tutorial_51_01
Arch_tutorial_51_01.png (28.71 KiB) Viewed 2923 times
Arch_tutorial_51_02.png
Arch_tutorial_51_02
Arch_tutorial_51_02.png (39.29 KiB) Viewed 2923 times
Arch_tutorial_51_03.png
Arch_tutorial_51_03
Arch_tutorial_51_03.png (9.89 KiB) Viewed 2923 times
your comments please
mario
Last edited by mario52 on Fri Mar 28, 2014 9:17 pm, edited 1 time in total.
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Sun Mar 23, 2014 4:50 pm

Comment:
The very first thing that one can state: That your affirmation it were a proper way is confirmed. Unbelievable and more over robust result! - Then firstly: nothing. ;)

Therefore:
I read a littel your code, the discription of it and I read of cause your post:

Code: Select all

This small macro allows you to build a project 3D very easily from a bitmap image 256 levels of gray.
I hope that this macro will revolutionize the way of thinking the CAD and CNC any image when what can be converted to object 3D without any intervention.
Maybe it is revolutionary. However the sentences need improvement to be understanded - should be corrected. My english is surely not the best.
Besides I would like to know in the introduction which is the exact use for which exact need. Ok, now I see what you made with my house, and I believe that one can wire-snap with it.
So I do not know for which useswhich solutions.
To say even now I still wonder. 8-)

-Import the image in Gimp
does gimp eat pdf? I think there should be a video-tutorial for it how one makes the imageprocessing bullet proof. And as well for the processing in FreeCAD.
f = open(OpenName, "rb")
I read a little your code and see that you opened the bmp with python standard tools.
But there the signal - for me - ends. Which method do you use? Do you use other libraries for it or is it your own magic?

Surely do not get me wrong. Your tool could be great. But description of system and application needs to be improved.
this all could be more diplomatic :oops: but its my comment on it.

Yes, and as I said when the other methods fail, e.g. I get old paper ground plans, then I will follow your advice try out and compare your vectorize methode with that of inkscape..
And leave a comment here.

Regards
mario52
Posts: 2921
Joined: Wed May 16, 2012 2:13 pm

Re: How to handle pdf import properly and feasibly?

Postby mario52 » Mon Mar 24, 2014 12:34 pm

hi
teobo wrote:Maybe it is revolutionary. However the sentences need improvement to be understanded - should be corrected. My english is surely not the best.
Besides I would like to know in the introduction which is the exact use for which exact need.
my English : french translated into English by bing translator and I do not know if the translation reflects my thoughts.
teobo wrote:Besides I would like to know in the introduction which is the exact use for which exact need.
convert a bmp image and vectorise for use in FreeCAD for any use.
teobo wrote:Ok, now I see what you made with my house, and I believe that one can wire-snap with it.
So I do not know for which useswhich solutions.
I saw that you have not downloaded the file Maison_02.FCStd this is what you want to do ? create your plan with FreeCAD as simply as possible ?
teobo wrote:does gimp eat pdf ?.
Yes Gimp open PDF files (File > Open > select "PDF (Portable Document Format) (*.pdf)) or extract the image in your .pdf file.
teobo wrote:
teobo wrote: f = open(OpenName, "rb")
I read a little your code and see that you opened the bmp with python standard tools.
But there the signal - for me - ends. Which method do you use ? Do you use other libraries for it or is it your own magic ?
nothing magical, documentation and research on the internet (I work with Python for a few months) your opinion on my programming ?

Code: Select all

 f = open(OpenName, "rb") # Open a file for binary file read
teobo wrote:Surely do not get me wrong. Your tool could be great. But description of system and application needs to be improved.
this all could be more diplomatic :oops: but its my comment on it.
I'm working. I see so many opportunities that I'm a little lost !
teobo wrote:Yes, and as I said when the other methods fail, e.g. I get old paper ground plans, then I will follow your advice try out and compare your vectorize methode with that of inkscape..
My macro is not equivalent or in cleanliness and finish if you work far your BMP image you should not correct it in FreeCAD if you follow my procedure, the single pass with FCTexture will give you your plan scale 1/1 and you will be able to use all the tools available in FreeCAD. (For the memory : in the image .BMP, the distance between 2 points = 1 mm) your plan is very easy, they are all straight lines.

PS : is that the image belongs to you ? If it is not your, I'll do another example with a picture of the wiki.
regards
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Thu Mar 27, 2014 5:51 pm

Hi Mario,
no, the image is actually not mine. If you take it, I beleave, nobody will notice that, even though.
Thanks for that work on the wiki.
bye
jmaustpc
Posts: 9638
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to handle pdf import properly and feasibly?

Postby jmaustpc » Fri Mar 28, 2014 4:54 am

teobo wrote:Hi Mario,
no, the image is actually not mine. If you take it, I beleave, nobody will notice that, even though.
Thanks for that work on the wiki.
bye
Teobo
we can't use images/files etc. in the wiki, if the copy right is not clear.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: How to handle pdf import properly and feasibly?

Postby teobo » Fri Mar 28, 2014 4:26 pm

jmaustpc wrote:
teobo wrote:Hi Mario,
no, the image is actually not mine. If you take it, I beleave, nobody will notice that, even though.
Thanks for that work on the wiki.
bye
Teobo
we can't use images/files etc. in the wiki, if the copy right is not clear.
Yes, you are right. My knowledge is exceeded in front of the question if this peace of graphic touches someone else`s rights.