Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

converting Number Value to string

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
jstraub78
4995 Views, 4 Replies

converting Number Value to string

Hello,

 

What's the easiest rule/function for converting the value from a number rule to a string?

 

For example, I have...

 

Rule DoorWidth As Number = 21

 

 

What I would like end up with is an additional rule like this, based off of the DoorWidth value:

 

Rule DoorWidthString As String = "21"

 

I'm just trying to convert a numerical value, evaluated from a rule, to a string.  I know this can be done with :Name rules, by using the MakeString function, but I'm not sure how to change the value of a numerical rule to a string.

 

I imagine I'm missing something obvious.

 

Thanks!

 

Joe

4 REPLIES 4
Message 2 of 5
jstraub78
in reply to: jstraub78

Nevermind,

 

It looks like the "StringValue" function is what I was looking for. 

 

Well, now I know 🙂

Message 3 of 5
rsimington
in reply to: jstraub78

You can also use format(%d,expression) or format(%g,expression). %d will round a number to an integer, whereas %g will keep it a decimal.

Message 4 of 5
jstraub78
in reply to: rsimington

Thanks, that could be handy as well!

Message 5 of 5
ebachrach
in reply to: jstraub78

Hi,

Be aware that stringvalue is not intended to reliably format the output.

 

For that you use the format function which uses C like notation, such as

Intent >format("my number is %g",2.301)
--> "my number is 2.301"
Intent >format("my number is %3.2g",2.301)
--> "my number is 2.3"

 

-- 

Autodesk 

Elly Bachrach 

Manager 

Manufacturing Consulting Services - ETO 

Direct      +1 (847) 676-2880 

elly.bachrach@autodesk.com

format("my number is %3.2g",2.301)

--
Autodesk
Elly Bachrach
ETO/CTO Solutions Designer
Intelligent Configuration Solutions
Mobile +1 (773) 401-6980
elly.bachrach@gmail.com

************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report