PDF inside the project

A forum dedicated to the Draft, Arch and BIM workbenches development.
philixx88
Posts: 8
Joined: Thu Jul 25, 2019 8:52 am

PDF inside the project

Postby philixx88 » Mon Jul 29, 2019 7:16 am

Good morning everyone!
Is there a way in FreeCAD 0.18 (windows) to upload PDF file inside the project?
Thank you!

F
User avatar
yorik
Site Admin
Posts: 12064
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: PDF inside the project

Postby yorik » Mon Jul 29, 2019 1:57 pm

This is doable but only via python:

You can add a new FileIncluded property to any object (it must be a python-defined object - object.TypeID must be App::FeaturePython or Part::FeaturePython or any other that ends with Python) like this:

Code: Select all

myObj.addProperty("App::PropertyFileIncluded","AttachedPdfFile")
myObj is your object, you can get the currently selected object with:

Code: Select all

myObj  FreeCADGui.Selection.getSelection()[0]
and "AttachedPdfFile" can be anything (use the CamelCase convention). After that your object will have a new "Attached Pdf File" property, that you can set to a pdf file. That file will be embedded into the FreeCAD file.

When opening the FreeCAD file, a temporary folder is created, and inside that temporary folder, there will be a read-only version of the pdf file.
User avatar
Kunda1
Posts: 8710
Joined: Thu Jan 05, 2017 9:03 pm

Re: PDF inside the project

Postby Kunda1 » Mon Jul 29, 2019 2:43 pm

yorik wrote:
Mon Jul 29, 2019 1:57 pm
This is doable but only via python:
Is this a feature that can be requested for the BCF GSoC project ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
philixx88
Posts: 8
Joined: Thu Jul 25, 2019 8:52 am

Re: PDF inside the project

Postby philixx88 » Mon Jul 29, 2019 6:19 pm

yorik wrote:
Mon Jul 29, 2019 1:57 pm
This is doable but only via python:

You can add a new FileIncluded property to any object (it must be a python-defined object - object.TypeID must be App::FeaturePython or Part::FeaturePython or any other that ends with Python) like this:

Code: Select all

myObj.addProperty("App::PropertyFileIncluded","AttachedPdfFile")
myObj is your object, you can get the currently selected object with:

Code: Select all

myObj  FreeCADGui.Selection.getSelection()[0]
and "AttachedPdfFile" can be anything (use the CamelCase convention). After that your object will have a new "Attached Pdf File" property, that you can set to a pdf file. That file will be embedded into the FreeCAD file.

When opening the FreeCAD file, a temporary folder is created, and inside that temporary folder, there will be a read-only version of the pdf file.
thank you, I'll try this method! :)
User avatar
yorik
Site Admin
Posts: 12064
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: PDF inside the project

Postby yorik » Tue Jul 30, 2019 10:24 pm

Kunda1 wrote:
Mon Jul 29, 2019 2:43 pm
Is this a feature that can be requested for the BCF GSoC project ?
There is not much to do with BCF. But in any case the feature is there already.. Not usable via the GUI, but then it would need more definition to know what should be implemented, and how, and where...