Parametric Text to display value

Parametric Text to display value

mark4017
Contributor Contributor
1,887 Views
10 Replies
Message 1 of 11

Parametric Text to display value

mark4017
Contributor
Contributor

i would like the parametric text to display just the value of a parameter without the unit of measure,  i want the value to be displayed not the expression 

mark4017_0-1758498115205.png

 

0 Likes
Accepted solutions (1)
1,888 Views
10 Replies
Replies (10)
Message 2 of 11

Warmingup1953
Advisor
Advisor

Expression and value probably can't be swapped, I am almost certain. In what case do you find this Standard inappropriate?

0 Likes
Message 3 of 11

mark4017
Contributor
Contributor

i was hoping there would be an option  to do something like  value -(unit) 

mark4017_0-1758498933543.png

 

 

0 Likes
Message 4 of 11

HughesTooling
Consultant
Consultant
Accepted solution

Looks like Value/units works.

HughesTooling_0-1758526567972.png

 

Mark Hughes
Owner, Hughes Tooling
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Message 5 of 11

mark4017
Contributor
Contributor

that worked , thank you

 

Message 6 of 11

ccyokes
Advocate
Advocate

If you find a way to display 1.5 as 1 1/2 instead, I'll be glad to share with the other posts on this parametric text. That's the last remaining unknown I am aware of that the official documentation decided wasn't important to include.

 

For anyone who happens to see this post instead of the others first, an apostrophe can be typed by using the escape character \. For example 'can\'t'. This also works to add a tab or new line with \t and \n respectively. Since parametric text is forced and not optional, this escape character is critically important to be able to use a textbox as... a textbox.

 

Probably a bug that will get patched out, but for now at least you can use the textbox shortcut to start a sketch and then the textbox is normal instead of parametric. For me (don't remember if this is default or not) this is done by pressing Ctrl+T while on the Solid tab (rather than the sketch tab).

0 Likes
Message 7 of 11

ChrisHeerschap
Enthusiast
Enthusiast

Huh, unintuitive and undocumented, but it does work. Thank you!

 

Would be nice to be able to change the output units - if I enter "4 in" in a parameter that is in a metric document, the parameter expands to '101.6 mm'.

 

Now how about controlling the formatting of the number, like {param.value:.3f} in the Parametric Text plugin? So 1.093347 shows up as "1.093".

 

Or zero padding a version number like {_.version:02d} so design version 4 displays as "04".

 

Both are basic capabilities that I use regularly.

 

Was initially excited to see that plugin's capability integrated into Fusion but quickly discovered it's far more limited. Looks like I'll be continuing to use the plugin for the foreseeable future.

Message 8 of 11

ChrisHeerschap
Enthusiast
Enthusiast

First, a correction - 1.093347 would display as 1.093 by default. Thought this might be set in the document settings, but can't find it there.

 

Digging through the docs, I did find that you can use the "floor(param)" function to drop the decimal. The manufacturing function reference lists "floorto" which drops anything past the number of decimal places specified, but this doesn't look to be supported in the design tab so can't be used in parametric text.

 

You can fake around it by using "floor(param*10)/10" to get a single decimal point - or "round(param*10)/10" depending on how you want it to work. eg, 90.25 becomes 90.2 with floor and 90.3 with round.

 

You can fancy it up by creating a unitless user param "decimals" and then change the above to: "round(param*10^decimals)/10^decimals". Big problem here is if you want four, tough cookies, because of the correction at the top, you run out at 3 decimal places. Not likely a real problem, (for me at least) but still a limitation.

 

Setting decimal places and dropping the units then becomes: "round(param * 10 ^ decimals) / 10 ^ decimals/ mm". It works, but... ewww.

 

It sure would be nice to just be able to use printf formatting codes which are so native for those of us who understand them. (like the PT plugin!)

 

Still haven't figured out how to reference document-specific things like document filename version, the active configuration description, or the comment on a parameter.

 

 

Message 9 of 11

ChrisHeerschap
Enthusiast
Enthusiast

You could probably write a really ugly function that converts "1.5" to "1 1/2" but it would be really non-trivial, especially since we're missing the most basic functions like fp() to return the floating point portion of a value, so returning just the ".5" of "1.5" with the available functions itself is tricky enough.

 

So I managed to write this up which works only for quarters. (and it turns out, not even that)

 

Create parameterValue
fp( floor(param * 100) - floor(param) * 100 ) / 100
fractionif(fp == 0.25 mm; '1/4'; if(fp == 0.5 mm; '1/2'; if(fp == 0.75 mm; '3/4'; '')))
textfloor(param) / mm + ' ' + fraction

 

Anything other than an exact quarter gets dropped, and for some reason the "3/4" case fails, it returns "fp" of 0.75 mm but the "if( fp = 0.75mm;" conditional fails. It seems like fp is somehow different. Stumped on this one but giving up after fighting it for a bit.

 

Might be a simpler way to do it but I'm not seeing it based on the documentation and my own experimentation.

 

0 Likes
Message 10 of 11

HughesTooling
Consultant
Consultant

@ChrisHeerschap You can get the floating point portion using parm % 1mm but it doesn't work in the if statement correctly. Oddly it only works with the quarters less than 1 and 1.75mm but fails with pretty much all other numbers ending with a quarter! Don't know if there's some rounding going that shows as the value but the if statement is using an unrounded value.

HughesTooling_0-1760713795383.png

 

Mark Hughes
Owner, Hughes Tooling
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


0 Likes
Message 11 of 11

john.koerner
Autodesk
Autodesk

This solution is very close, but it fails due to how Fusion internally stores some of these values and due to floating point representation of the numbers.  We can change the functions a bit to achieve the desired result by working with whole numbers that have been rounded to ensure accuracy.  

 

fp round(Test % 1 mm * 100)
fraction if(fp == 25 mm; ' 1/4'; if(fp == 50 mm; ' 1/2'; if(fp == 75 mm; ' 3/4'; '.' + fp)))
text floor(Test) / mm + '' + fraction

 

 

johnkoerner_1-1760734093116.png

 

John Koerner