Inventor Engineer-to-Order

Reply
Valued Contributor
johnasp1
Posts: 101
Registered: ‎05-30-2006
Message 1 of 4 (123 Views)

decimal

123 Views, 3 Replies
01-31-2013 10:01 AM

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 

Contributor
omarutov
Posts: 16
Registered: ‎10-19-2012
Message 2 of 4 (120 Views)

Re: decimal

01-31-2013 10:26 AM 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.
Employee
JackGregory
Posts: 189
Registered: ‎03-06-2006
Message 3 of 4 (110 Views)

Re: decimal

01-31-2013 11:31 AM 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

 

Valued Contributor
johnasp1
Posts: 101
Registered: ‎05-30-2006
Message 4 of 4 (93 Views)

Re: decimal

02-01-2013 09:25 AM 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, :smileyfrustrated:econd})


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"}

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube