Launch Non-FreeCAD Files

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Launch Non-FreeCAD Files

Post by rich61 »

I use the Tools - Add Text Document. I've wished I had LibreOffice Writer sometimes. From the File menu it is possible to open a png image for example, and it does display in the window. If open an SVG file, FreeCAD actually interprets it and displays it, however it doesn't use inkscape to do it. It doesn't add those files into the freecad project tree however.

I would like to add a libreoffice writer document to the tree, so it is easily launchable from within my freecad project, and permanently associated or linked to my project tree. Is there a way to do that now ?

I could see this being useful for inkscape, various image manipulation programs, and possibly other apps as well as libre writer text documents. Any file that is linked to the project would simply launch the system app associated with that file type. The only support in FeeCAD would be the project link, the app would display in its own window, etc.

Of course I can do all this by just opening a new libreoffice window, but its just a convenience to associate various other tools and files with the FreeCAD project tree. There would be no other integration with FreeCAD functionality.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Launch Non-FreeCAD Files

Post by onekk »

rich61 wrote: Mon Mar 13, 2023 2:39 pm ...
Not clear your intent, but some thing to note:

- For security reason every unattended launch of scripts and other external software is a "good thing" that it will not be automatic, if not there are space for malware to be injected in FreeCAD files. This has been discussed various times between developers.

A more general consideration:

Why make FCStd file a container for many other things other than the model itself?

For now "Text Document" could be added and has proven to be useful as example to supply instructions on how to do things, maybe
when there are some spreadsheet involved and you have to explain to the potential user what field use to obtain things.

In this case probably some sort of formatting could be useful, but probably to avoid to clutter FreeCAD with too many things, some lightweight markup format, like the html subset already supported by Qt5/Qt6 that probably will suffice for most tasks.

https://doc.qt.io/qt-6/richtext-html-subset.html

LibreOffice is a vey good program, but probably something less invasive will make things more easy to implement without making FreeCAD grow in size and complexity.

about SVG Take in account that despite Inkscape is OpenSource many users have noted that it clutter the produced SVG file with "personalized code" that could be used only by InkScape itself, if you analyze a source you will easily see that it contains many metadata that are useful only to edit the same file in InkScape, and are not useful to visualize the file in a standard SVG viewer.

So even here some considerations are to be made, as InkScape is aware of this problem:

https://wiki.inkscape.org/wiki/index.ph ... leaned_SVG

I hope that other user maybe @yorik that if I remeber well has probably the most deep knowledge of this matter.

Kind Regards.

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Launch Non-FreeCAD Files

Post by rich61 »

I probably wasn't clear enough in my description.

Regarding your comment: Why make FCStd file a container for many other things other than the model itself?

I wasn't suggesting this be integrated with FreeCAD nor saved in the FreeCAD FCStd files, and I don't think this means it is in the FreeCAD container. In fact there would be no connection or file sharing whatsoever. It is still entirely external except for the convenience-launcher.
1. It would list in the Tree only for convenience
2. It could launch the associated app by issuing a system command

Any use of the text file would be in the LibreOffice app. FreeCAD would never open the LibreOffice file.

FreeCAD would only store the name in the project tree. This would make files that are unrelated to FreeCAD design files, to still be "associated in mind" with the project. Its just a way to keep track of additional support documentation associated with the project, and to make it easy to launch.

I don't see it as creating any more opportunity to inject malware than if I launch the app from outside FreeCAD. There is no data connection what so ever except the collection into the tree. If the external app would save the file within its own save menu.

Once the app and its file is launched conveniently from the project tree, FreeCAD would have no further role with the app.

And, you get a super nice text editor for free and maintained by someone else.
User avatar
bambuko
Veteran
Posts: 2161
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Launch Non-FreeCAD Files

Post by bambuko »

@rich61
Yes, I like this idea!
For anyone who uses FreeCAD as a design tool (as opposed to 3D modelling tool) it is desirable (in my humble opinion) for a FreeCAD file to be container of some kind for all the design intent notes, using external tools for handling those.

At the moment my "design intent" container is a project folder on my PC, which contains FreeCAD files, 2D CAD files (in my case QCAD), spreadsheets, text files (I don't use Libre Office, but that's another story) as well as images.

Every project has it's own folder, but there is really no connection between all the elements.
Using FreeCAD for that would be an interesting development...
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Launch Non-FreeCAD Files

Post by rich61 »

Thanks for the input.

I think the initial creation of the documentation file would be done in libreoffice writer, not in FreeCAD for minimum impact on FC. Then after you open your normal project file in FreeCAD you would open the doc file, and you could have the option to add it to your project tree, its just a path link. After that FreeCAD would do no more than what linux nautilus does, just launch the file with its associated app. It helps remember the file exists in support of the project.

Its not really something everyone needs I guess, just helps keep the mind straight about which files you are using with your FC project.

I use a desktop icon to easily locate and prompt the projects I'm working on. This is ubuntu/linux specific, but it gets me to my disk directory with all the freecad projects, and I add additional 2nd and 3rd line args just for the projects I'm currently working on, so I edit the Desktop file to be current, so I have quick access project tabs in pcmanfm.

I probably could find a way to not only display and launch the FC project this way, but to also show my libreoffice doc file if I stick to a naming convention.

[Desktop Entry]
Name=FreeCAD Dir
Type=Application
Exec = pcmanfm /home/rich/FreeCadFiles /home/rich/FreeCadFiles/Project1 /home/rich/FreeCadFiles/Project2
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Launch Non-FreeCAD Files

Post by onekk »

The problem coukd be seen from a different point if view.

like a makefile in a sort of sphinx like workflow, I'm experimenting with sphinx to document some compkex scripts, and the file is a written in restructured text, but it read the python code and format retrieve docstrings from the code to produce a documentation of the code.

a python script that read a text file that definites directive to execute to prepare a directory tree, a sort of:

docs
src
3df
step
stl

and maybe a makefile that define sone actions.

it coukd be a good proposal as it could be fairly flexible and even check if all the programs are present in the init phase.

so the eventually zipped file coukd a:

make check-env directive that will check if the destination machine as all the machinery: FreeCAD (maybe even checking what version is present) LibreOffice, Inkscape, Kicad, even Latex for a complete manual.

a make docs will prepare some other things

make manual will maybe prepare the manual

all could be defined like in sphinx were all the directives are contained in two files (index.rst and a conf.py)

But is only an idea.

It will be even fairly portable as this workflow seems to be used across different OS.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Launch Non-FreeCAD Files

Post by adrianinsaval »

onekk wrote: Mon Mar 13, 2023 4:25 pm In this case probably some sort of formatting could be useful, but probably to avoid to clutter FreeCAD with too many things, some lightweight markup format, like the html subset already supported by Qt5/Qt6 that probably will suffice for most tasks.
supporting markdown would be a better idea IMO

As for external files opened in external programs from within freecad... what is the point? If the file is fully independent from the model I see no value in this. FreeCAD isn't a file manager.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Launch Non-FreeCAD Files

Post by GeneFC »

adrianinsaval wrote: Mon Mar 13, 2023 8:11 pm FreeCAD isn't a file manager.
I suspect this would lead to an endless stream of:

"FreeCAD will not open my files (and file applications) on xxx OS."

There is already this sort of problem with pure (FCStd) FreeCAD files. When trying to extend to applications over which FreeCAD has no control the problem is sure to multiply.

Gene
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Launch Non-FreeCAD Files

Post by rich61 »

Onekk, I think the makefile model is over doing it. Plus, I'd prefer that FreeCAD doesn't do anything with the target file, although It is convenient to know the file exists and where it is by the path, as would be shown in the tree. I would want to still edit using LibreOffice directly, independent of FC. Its just a project external file list that you can launch by clicking it.

And adrianinsaval,
.. what is the point? If the file is fully independent from the model I see no value in this. FreeCAD isn't a file manager.
You are correct that it is fully independent of the model, but it is not independent of the project. Maybe FC isn't a project manager either, but essentially manages part files in an assembly, for example. The documentation is part of the project, but not the model. Most users are probably manually doing their own project files management now simply by putting things all in one directory. But it would also be nice to keep track of things in a different directory.

It seems that the File Open menu is agnostic, and allows an attempt to open any extension.

But for an extension of ".odt" a python system command "libreoffice --writer <arg>" would do the job. Simple, and helps for people that don't remember the path or name of the writer file, when they have about 20 different projects.

Although I've been thinking mostly of ".odt" files, I also get pdf files or even step files from a manufacturer. Those could also be in the tree under a level called something like "External Reference Documents". And they would normally be used in several projects, so there need be only one file. This way FC could contain a list of all the backup references and documents that pertain to the design.

And, its CHEAP. Other than launching the app on the file pathname, there is almost no coding burden. Although I'm probably not thinking of something.

And GeneFC, I guess this function could default to off in the preferences. Since it would use the OS command line, I don't see where it would create so many problems. Any problems are in the OS app, once launched to the OS command line, FC is out of the picture.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Launch Non-FreeCAD Files

Post by adrianinsaval »

but essentially manages part files in an assembly, for example.
but this is not the same situation, because these are also FCStd files and can be used for actual modelling, they aren't just shortcuts to open the file somewhere else.
Maybe FC isn't a project manager either
bingo!
IMO this is out of the scope of the main project. Perhaps it could be implemented in an addon (like the PLM stuff that was discussed some time ago).
But for an extension of ".odt" a python system command "libreoffice --writer <arg>" would do the job.
No this won't work, what if I don't have libreoffice installed? or what if I have it but want it open on some other software? what if I'm using flatpak or snaps or appimages? or I'm on windows where applications are almost never in the path? does this even work on mac? In reality for something like this to be remotely useful you have to use some API to ask the host OS to open the file with whatever it has defined as the default application, I'm guessing this varies between win/linux/mac, perhaps Qt has some cross-platform function for this that can be leveraged.
In your mind this is very simple because for your system you know exactly what to do (it's always "easy" when you are not the one actually implementing it isn't it?), but this doesn't translate as seamlessly as you think to all other systems
Post Reply