cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

length of a string in points APP

otudor
8-Gravel

length of a string in points APP

Hi,

 

How can I get the length of a string in points? (not the number of letters)

 

Florin

1 ACCEPTED SOLUTION

Accepted Solutions

You're meant to run this during formatting so it picks up the current formatting properties. I haven't tested what it does outside of formatting context, it will pickup some defaults, but you can use PIs in the text string I believe (or wrap it in a styleSave(), styleChange(), and styleRestore()).

View solution in original post

5 REPLIES 5

Here are a couple of options to measure a string:
APP code: <?show $^(#"Testing")>
JS code: var l = fLength(); l.text = 'Testing'; application.alert(l.makeAbsolute());

Hi Gareth,

for application.alert(l.makeAbsolute()); statement I get a message of "69.5666mm" and for

application.alert("length : " + l.makeAbsolute()); statement I get a message of "695666" only.

 

Do you know why? and in what unit is the second message? micrometers?

 

mak.png mak2.png

Florin

 

 

 

The second way you're forcing to a string value, the first is returning an fLength. The second value is in APP's base measurement units known as "decimicrons". You can use these units everywhere in APP by using the "dm" unit suffix.

One last question. Is this solution taking in consideration the font size and family which have been set prior measuring the string?

 

Thank you!

 

Florin

You're meant to run this during formatting so it picks up the current formatting properties. I haven't tested what it does outside of formatting context, it will pickup some defaults, but you can use PIs in the text string I believe (or wrap it in a styleSave(), styleChange(), and styleRestore()).

Top Tags