Draft label with hyperlink

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
PeterPNoster
Posts: 72
Joined: Mon Sep 02, 2019 8:24 pm
Location: Switzerland

Draft label with hyperlink

Post by PeterPNoster »

Dear community,
Is it possible to set an draft label on the 3D Part and set up an hyperlink, to an internal/external document, such as a pdf drawing or a text document?
Click on the draft label and the system viewer displays the document.

Cheers, PeterPNoster
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Draft label with hyperlink

Post by heda »

do not think there is now, but sounds like a really nice feature to have.

if nothing else, should be possible to do with a macro, with a document/selection observer it ought to be possible to get a trigger working upon selection - doing the system call from that is trivial.
PeterPNoster
Posts: 72
Joined: Mon Sep 02, 2019 8:24 pm
Location: Switzerland

[feature request]Re: Draft label with hyperlink

Post by PeterPNoster »

Dear heda,
I agree, this could be a very nice feature.
The context. I try to build up an existing product in FC. That product is easily configurable, but the assembling process is quite complicated.
So, the plan is to build that product in FC and put here and there a few annotation labels with additional information saved in an external documents.

Unfortunately my macro skills, aren't that good, maybe someone could build it. :)

I've opened a feature request: https://github.com/FreeCAD/FreeCAD/issues/7062
User avatar
calligarov
Posts: 47
Joined: Sun Jan 01, 2023 3:08 pm
Location: Cadore, Italy
Contact:

Re: Draft label with hyperlink

Post by calligarov »

Hi Everyone! 😃

After some research, coding and tests, I just opened a pull request for the modifications needed to use the hyperlinks in Draft WB.
This is the link to the GitHub Pull Request, issue #10878.

How it works:
  • the command allows the selection of multiple object, even multiple texts.
  • for every text a regex will be applied. If at least one text contains at least one hyperlink the command will be added to the context menu.
  • when called the command, in case of multiple hyperlinks a message box will inform that multiple windows could open (one for every hyperlink)
  • for every hyperlink a subprocess will launch the application related to the file type / protocol and open the file/page described by the hyperlink
Some notes:
  • the regex accepts spaces in the hyperlink only before the first dot, which is supposed to be the beginning of the file extension. Issues may arise if there are combinations of dots and spaces in the path of the file or in the filename itself (for example /home/vincenzo.calligaro/some folder with spaces/file.txt will fail due to the dot in the folder vincenzo.calligaro and the following spaces in the folder "some folder with spaces")
  • the code should already be platform independent and support Windows, macOS and Linux but ATM I tested it only on Linux (Linux Mint 21 Cinnamon)
  • the code to actually open the files in the hyperlinks, launching the correct application, is more or less what I found here: https://stackoverflow.com/questions/173 ... -startfile
As always, feedback are very welcome! 😉
You can find some more info about me at https://wiki.opensourceecology.org/wiki/User:Calligarov

My GitLab profile: https://gitlab.com/calligarov
Post Reply