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: 
Reply
Message 1 of 4
johnasp1
256 Views, 3 Replies

decimal

I have a list of numbers from a database and in the data base the first number has 2 places past the number

Example {2.00, 1.9}.

    When I grab this number it looks like this {2.0, 1.9}.....I need 2 places past the number.

I tried  to format to a string then change back to a number but no luck.

 

Intent >format("%3.2f",2.0 )
--> "2.00"

Intent >makeNumber("2.00")
--> 2.0

 

John 

3 REPLIES 3
Message 2 of 4
omarutov
in reply to: johnasp1

If you need to show your number on the drawing, use Styles. You need create new Dimension style with checked Trailing Zeros in Unit Tab - Display. Select precision as 2.12. In Intent code when you will create Dimension Child use dimStyle parameter as "here name your Dim Style". Should work.

Win7 x64
Xeon X5647
24 Gb RAM
Quadro FX 6000

Inventor 2013
ETO 6.1, Build 140.
Message 3 of 4
JackGregory
in reply to: johnasp1

Numbers have the same precision internally all the time.  What you see as the representation is a function of what is doing the output.  If you have a real number in a database, it is 2, 2.0, 2.00000000 all at the same time.  Intent's various UIs have different standards.  There are also functions which can format numbers to a string.  But there isn't any loss of precision.

 

You say, "When I grab this number"..   What does that mean?  Then you say you need 2 places past the number, but you seem to indicate that you don't want a string.  So where do you want 2 places that isn't a string?

 

--Jack Gregory

 

Message 4 of 4
johnasp1
in reply to: JackGregory

As it turns out I was able to use a string as my final output so I used the format() function.

Here is an example:

 

original list:
Intent >data.set
--> {{1.38, 12.0}, {1.38, 9.0}, {1.68, 9.0}, {1.68, 9.0}, {2.0, 7.5}, {2.0, 6.0}, {2.0, 6.0}, {2.0, 9.0}, {2.0, 9.0}, {2.0, 7.5}, {2.2, 4.5}, {2.2, 6.0}, {2.2, 6.0}, {2.2, 7.5}, {2.2, 9.0}, {2.2, 9.0}, {2.2, 7.5}, {2.2, 4.5}, {2.4, 6.0}, {2.4, 7.5}, {2.4, 6.0}, {2.4, 4.5}, {2.4, 7.5}, {2.4, 4.5}}

 

Rule Run As Any = sort(RemoveDuplicates(data.set), :Ascending, key := {:first, :Second})


Rule Run1 As List
Run1 = {}
Dim x As Any
Dim dataList As Any = Run
For Each x In (dataList)
Run1 = Run1 +{{format("%3.2f",nth(1,x)), format("%3.1f",nth(2,x))}}
Next x
End Rule

Rule Run2 As List
Run2 = {}
Dim x As Any
Dim dataList As Any = Run1
For Each x In (dataList)
Run2 = Run2 +{nth(1,x) + (If MakeNumber(nth(2,x))>=10 Then "__" Else "___") + nth(2,x)}
Next x
End Rule

Intent >run2
--> {"1.38___9.0", "1.38__12.0", "1.68___9.0", "2.00___6.0", "2.00___7.5", "2.00___9.0", "2.20___4.5", "2.20___6.0", "2.20___7.5", "2.20___9.0", "2.40___4.5", "2.40___6.0", "2.40___7.5"}

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

Post to forums  

Autodesk Design & Make Report