You are a unique anomaly.
Launch Non-FreeCAD Files
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Launch Non-FreeCAD Files
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Launch Non-FreeCAD Files
I haven't been in the habit of using Label2, thanks for mentioning it.
Only one problem, when I click it, it doesn't open the PDF file.
Edit: I mocked up the image a bit, that shouldn't be a // but just a single / in the path name
Only one problem, when I click it, it doesn't open the PDF file.
Edit: I mocked up the image a bit, that shouldn't be a // but just a single / in the path name
Re: Launch Non-FreeCAD Files
Just an FYI.
Two lines of Python will perform said launching.
(Here on Linux, but, probably similar on other platforms.)
The following is entered at the python console and assumes the odt file exists.
There is apparently other magic needed to have it run as a macro/Python file. (If anyone knows this magic, please edificate me... ) Run from a Python file it complains about the the subprocess module can't be found...something to do with shibroken2...(shiboken2, it's always some dang thing with shiboken )
Update: it works fine from both the FC Python console or a Python/macro file...it I make content of the file correct. Cut&Paste gets me again...
Two lines of Python will perform said launching.
(Here on Linux, but, probably similar on other platforms.)
The following is entered at the python console and assumes the odt file exists.
There is apparently other magic needed to have it run as a macro/Python file. (If anyone knows this magic, please edificate me... ) Run from a Python file it complains about the the subprocess module can't be found...something to do with shibroken2...(shiboken2, it's always some dang thing with shiboken )
Code: Select all
import subprocess
>>> process_one = subprocess.Popen(['libreoffice', '\\home\\mac\\Documents\\afile.odt'])
Last edited by drmacro on Tue Mar 14, 2023 2:43 pm, edited 1 time in total.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Launch Non-FreeCAD Files
I got this to work from the command line.
python3 -m webbrowser [ url or file path here ]
the browser may come up with a save or open dialog.
Works equally well with local file path
python3 -m webbrowser [ url or file path here ]
the browser may come up with a save or open dialog.
Works equally well with local file path
Re: Launch Non-FreeCAD Files
Thanks drmacro for this. It works fine in an older apt and also app install, but I get an error with my snap version.
My non-snap versions are different freecad versions.
But fails in my snap install.
My non-snap versions are different freecad versions.
Code: Select all
import subprocess
p=subprocess.Popen(['firefox', 'example.com'])
Code: Select all
>>> import subprocess
>>> p=subprocess.Popen(['firefox', 'example.com'])
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/snap/freecad/655/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/snap/freecad/655/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'firefox'
>>>
Code: Select all
OS: Ubuntu Core 20 (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.0.32235 (Git) Snap 655
Build type: Release
Branch: master
Hash: 4ed6150231c27968e142bf5cac80d9cfe626f24b
Python 3.8.10, Qt 5.15.5, Coin 4.0.0, Vtk 7.1.1, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods:
* Assembly3 0.11.3
* fasteners 0.4.54
* ThreadProfile 1.84.0
- adrianinsaval
- Veteran
- Posts: 5548
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Launch Non-FreeCAD Files
AFAIK you can't directly run other apps from a snap package because it is sandboxed, see it's not that simple of a feature
Re: Launch Non-FreeCAD Files
Thanks adrian, I didn't know that. A closed universe.
Re: Launch Non-FreeCAD Files
My 2 cents here:
1. The Label2 should be renamed to something more meaningful like "Description" or "Notes"
2. We could have an "Edit Label2" tool that could for ex:
- open a more advanced editor dialog
- detect rich/html text (and maybe more, such as markdown) and renders it correctly
- detect links and make them clickable
Such tool could probably more or less easily be don in python, a simple macro could do it. Then, once it works well, it could be integrated into the FreeCAD UI
1. The Label2 should be renamed to something more meaningful like "Description" or "Notes"
2. We could have an "Edit Label2" tool that could for ex:
- open a more advanced editor dialog
- detect rich/html text (and maybe more, such as markdown) and renders it correctly
- detect links and make them clickable
Such tool could probably more or less easily be don in python, a simple macro could do it. Then, once it works well, it could be integrated into the FreeCAD UI
Re: Launch Non-FreeCAD Files
I keep an external libreoffice document now, and embed hyperlinks to any other files such as PDF vendor drawings and specification documents on my file system or on the web, in my project directory to try to say organized. Its just a way to keep track of reference documents that relate to the model. Everyone has a system.
Just a few examples what could be done if its worth it. Just bring up a context menu on one of the Text document list, and open the system level link in the OS environment.
1. Existing Internal Text document
2. detect a link or command, launch external file
3. Just the file only and the OS decides how to open it
4. A web link, not sure I like that since it could distribute a bad site
When FCStd files are distributed, the external files would not be included in the FreeCAD file. So to distribute them would be a deliberate action.
The property Label2 is part of every object. Label2 always in the description column once entered.
An alternate approach is to have an external utility program read and parse the Document.xml file to get the links and any documentation in a Text Document or in the Description fields.
Just a few examples what could be done if its worth it. Just bring up a context menu on one of the Text document list, and open the system level link in the OS environment.
1. Existing Internal Text document
2. detect a link or command, launch external file
3. Just the file only and the OS decides how to open it
4. A web link, not sure I like that since it could distribute a bad site
When FCStd files are distributed, the external files would not be included in the FreeCAD file. So to distribute them would be a deliberate action.
The property Label2 is part of every object. Label2 always in the description column once entered.
An alternate approach is to have an external utility program read and parse the Document.xml file to get the links and any documentation in a Text Document or in the Description fields.
Re: Launch Non-FreeCAD Files
This is good and simple, actually. Maybe the label2 in the tree should become clickable if a link is detected? Not sure if it's such a good idea... Seems like an invite for spam/malicious links...