Draft.string from a parameters (or expression)

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!
AndreaMcNew
Posts: 2
Joined: Tue Apr 09, 2019 9:21 am

Draft.string from a parameters (or expression)

Post by AndreaMcNew »

Hello,
I'm looking for this function by so far, but until now I never found any thread or question about this.
I'm design a meccanical part, with some parameters taken from a spreadsheet object. I want to create different 3D printed samples with a different parameter (inclination), and reported it on the surface by a Draft.String object engraved.
Because this parameter is in the spreadsheet and used for three different expression in order to calculate the shape, would by very userfull if the string (the text) could by generated from that parameter, but I did't find any way to do it. Until now, the text in the string isn't generable with an expression (the expression icon is missing).
I started this project using the version 0.16, passing trough 0.17 beta, after a while the 0.17 stable and now I'm tring v0.19 from github, but never changed.
Also, I tried the way to use the string.string value as source, but isn't praticable, because it is a "string" type and the "expression" module seems to not have a casting function to convert it in float or integer.
Do anybody have the solution or tips?
Regards,
Andrea

Actual Freecad version:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16274 (Git)
Build type: Release
Branch: master
Hash: 7c760259a389b38b76da78e4f6e1f9be66714842
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Italian/Italy (it_IT)
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Draft.string from a parameters (or expression)

Post by jmaustpc »

Your first post, welcome to FreeCAD.
AndreaMcNew wrote: Tue Apr 09, 2019 9:41 am Until now, the text in the string isn't generable with an expression (the expression icon is missing).
Expressions has not been implemented yet for the "string" property of A Draft ShapeString.

I suggest you make a "feature request" ticket on the FreeCAD mantis bug tracker. Post a link to the ticket in this topic, and a link to this topic in the bug tracker ticket.

Yorik is the most likely to understand this and add it if he thinks its a good idea, he wrote most of Draft WB.
yorik wrote:
Hi Yorik, I discovered today that in Ubuntu on the command line you can type

Code: Select all

fc-list
and it lists all fonts on the system and their directories. Just wondered if that is Linux wide and if you could use that in some way to help selecting a font for the font property of Draft Shape String?

Jim
AndreaMcNew
Posts: 2
Joined: Tue Apr 09, 2019 9:21 am

Re: Draft.string from a parameters (or expression)

Post by AndreaMcNew »

Hi Jmaustpc,
Thanks for reply.
I'll try to make a feature request, but at this moment it seems I'm the only person interested in :roll: ...!
Bye,
Andrea
User avatar
meme2704
Veteran
Posts: 2926
Joined: Sat Apr 01, 2017 2:47 pm
Location: Vosges

Re: Draft.string from a parameters (or expression)

Post by meme2704 »

but at this moment it seems I'm the only person interested in
No you're probably not the only person to ask, but if not: then boff ... it surely come one day
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft.string from a parameters (or expression)

Post by Roy_043 »

Ideally every input field should have this feature IMO.
User avatar
dimitar
Posts: 229
Joined: Thu Jun 13, 2019 6:10 am
Contact:

Re: Draft.string from a parameters (or expression)

Post by dimitar »

yorik wrote:
I am also interested in custom text from parameters or expression. searching around the forums, can't seem to find much, besides this thread. To me it seems that the text should have the properties of a label, and label of text, with one being with a built-in leader and the other without. So maybe it is the label that could get updated to use custom parameter references of expression engine and be able to exist without a leader line.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Draft.string from a parameters (or expression)

Post by openBrain »

dimitar wrote: Sat Jan 22, 2022 1:49 pm I am also interested in custom text from parameters or expression. searching around the forums, can't seem to find much, besides this thread.
Is that what is in example file there? https://forum.freecadweb.org/viewtopic. ... =8&t=58657
User avatar
dimitar
Posts: 229
Joined: Thu Jun 13, 2019 6:10 am
Contact:

Re: Draft.string from a parameters (or expression)

Post by dimitar »

openBrain wrote: Sat Jan 22, 2022 3:08 pm Is that what is in example file there? https://forum.freecadweb.org/viewtopic. ... =8&t=58657
Yes! That's pretty cool! That expression possibility should be available to the regular draft text tool as well, so there is no need to create too much new real geometry by using the shape string tool.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft.string from a parameters (or expression)

Post by Roy_043 »

dimitar wrote: Sun Jan 23, 2022 4:03 pm expression possibility should be available to the regular draft text tool as well
It already is:
- Create the Arch_Text with a dummy string.
- Right click the "Text" field in the Property editor and select "Expression...".
- Enter f.e.: list(<<Cube length: %s>> % Box.Length; <<Cube width: %s>> % Box.Width; <<Cube height: %s>> % Box.Height)
User avatar
dimitar
Posts: 229
Joined: Thu Jun 13, 2019 6:10 am
Contact:

Re: Draft.string from a parameters (or expression)

Post by dimitar »

Roy_043 wrote: Sun Jan 23, 2022 6:34 pm It already is:
- Create the Arch_Text with a dummy string.
- Right click the "Text" field in the Property editor and select "Expression...".
- Enter f.e.: list(<<Cube length: %s>> % Box.Length; <<Cube width: %s>> % Box.Width; <<Cube height: %s>> % Box.Height)
Got it! A bit of a roundbout way, but it works! Thank you! This should be in the wiki.

The units though, don't mach the scene units. I am using meters, and I am getting a box.length in mm. I tried entering the following

<<Cube Length %s>> % Rectangle.Length * 1000

And i got 1000 copies of the 1.4m rectangle length! Yikes.

So what's the way to expand the expression with some more maths?
Post Reply