CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   CFX (http://www.cfd-online.com/Forums/cfx/)
-   -   Rounding Values in Post (http://www.cfd-online.com/Forums/cfx/112116-rounding-values-post.html)

stifelistefan January 22, 2013 11:15

Rounding Values in Post
 
Hi Everybody,

I'm trying to get the length of my geometry with the following expressions:

TEXT: X Abmass
Colour = 0, 0, 0
Font = Sans Serif
Position Mode = Three Coords
Text Colour Mode = Default
Text Height = 0.024
Text Position = (maxVal(X)@domair + minVal(X)@domair)/2, maxVal(Y)@domair + 2 [m], maxVal(Z)@domair
Text Rotation = 0 [degree]
Visibility = On
X Justification = Center
Y Justification = None
TEXT ITEM: Text Item 1
Auto Annotation Expression = (maxVal(X)@domair - minVal(X)@domair)
Auto Annotation File Date Format = DD/MM/YY
Auto Annotation File Time Format = h:m:s t
Auto Annotation Filename Format = Filename Only
Auto Annotation Type = Expression
Embed Auto Annotation = On
Text Item Active = On
Text String = <aa>
END
END

Unfortunately "(maxVal(X)@domair - minVal(X)@domair)" gives "33.7966 [m]"

Does anyone know how I can have it rounded to two digits? And if that's possible: to remove the units?

Thanks

mjgraf January 22, 2013 16:39

Off the top of my head not sure how to do that in an expression or CEL, but the Power Syntax can easily do it.

Create a session file
2 perl lines

Code:

! ($extent, $extent_units) = maxVal("X","DEF") - minVal("X", "DEF");
! $extent = sprintf "%.2f", $extent;

Then add the CCL code for the TEXT you already provided.
On the line Auto Annotation Expression
make it
Auto Annotation Expression = $extent

Example:

Code:

! ($extent, $extent_units) = maxVal("X","DEF") - minVal("X", "DEF");
! $extent = sprintf "%.2f", $extent;

TEXT:Text 1
  Colour = 0, 0, 0
  Font = Sans Serif
  Position Mode = Two Coords
  Text Colour Mode = Default
  Text Height = 0.024
  Text Position = 0 , 0.96
  Text Rotation = 0 [degree]
  X Justification = Center
  Y Justification = None
  TEXT ITEM:Text Item 1
    Auto Annotation Expression = $extent
    Auto Annotation File Date Format = DD/MM/YY
    Auto Annotation File Time Format = h:m:s t
    Auto Annotation Filename Format = Filename Only
    Auto Annotation Type = Expression
    Embed Auto Annotation = On
    Text Item Active = On
    Text String = Expression = <aa>
  END
END

Quote:

Originally Posted by stifelistefan (Post 403334)
Hi Everybody,

I'm trying to get the length of my geometry with the following expressions:

TEXT: X Abmass
Colour = 0, 0, 0
Font = Sans Serif
Position Mode = Three Coords
Text Colour Mode = Default
Text Height = 0.024
Text Position = (maxVal(X)@domair + minVal(X)@domair)/2, maxVal(Y)@domair + 2 [m], maxVal(Z)@domair
Text Rotation = 0 [degree]
Visibility = On
X Justification = Center
Y Justification = None
TEXT ITEM: Text Item 1
Auto Annotation Expression = (maxVal(X)@domair - minVal(X)@domair)
Auto Annotation File Date Format = DD/MM/YY
Auto Annotation File Time Format = h:m:s t
Auto Annotation Filename Format = Filename Only
Auto Annotation Type = Expression
Embed Auto Annotation = On
Text Item Active = On
Text String = <aa>
END
END

Unfortunately "(maxVal(X)@domair - minVal(X)@domair)" gives "33.7966 [m]"

Does anyone know how I can have it rounded to two digits? And if that's possible: to remove the units?

Thanks


stifelistefan January 23, 2013 03:32

Hi mjgraf

That work perfectly! Thanks for the quick reply!

stifelistefan January 23, 2013 11:21

HI again :-)
I have a new problem with probably a similar solution... (something in perl :-))

I would like to have my text position automated
Text Position = (maxVal(X)@domair + minVal(X)@domair)/2, maxVal(Y)@domair + 2 [m], maxVal(Z)@domair
is not good enough...

Is it possible that the text is right alined to the text position? And is it possible that the distance to the text position is constant (when changing the camera position in Post)?

Cheers

benadam10 March 5, 2014 09:10

You can use int() and nint() CEL functions


All times are GMT -4. The time now is 06:44.