[Вопрос] Smart Part STR function


Hi,

I have problem with writting a correct syntax to STR function. I would like to get rounded value (with one decimal characters) of float and if its ends on some_value.0 to just skip this ".0" to get only some_value

My current syntax is:

TEXT2 0,0, STR (%[0][10][1]m ,anchor_b)

anchor_b is a lenght type parameter

After checking a syntax I get information:

2D-Script:
---Error line 553.19: syntax error, unexpected tMOD

If you are able to solve my problem I can't wait a solution ;)

This is a part of on my own dimensions function to skip doing it after make a smart part. I'd like to safe ma time to clicking the ref points after creating a smart part. If you know a function in smart part with is related with dimension line in Allplan (instead of drawing line and putting a text in Smart Part) let me know. Ofcourse if you want ;)

I've attached a Print screen with my dim line to ilustrate my problem.

Вложения (1)

img
Smart_part_dimensions.PNG
Type: image/png
Загружено 30 раз
Size: 10,92 KiB

Show most helpful answer Hide most helpful answer

Hello,

The caracters "[" and "]" are only displayed to separate values in the help file. They are not to be inserted in the function.
Maybe, try something like this: STR ( "%.1m" , anchor_b )
It seems that the "~" flag doesn't works. Maybe this is another specific caracter...
So, you can make a test like this:

IF STR ( "%.1m" , FRA ( anchor_b ) ) = "0.0" THEN m_text = STR ( "%.0m" , anchor_b ) ELSE m_text = STR ( "%.1m" , anchor_b ) 

wizysmart.difraxis.com –––––––––––––––––––––––––––––

1 - 4 (4)
  • 1

Hello,

The caracters "[" and "]" are only displayed to separate values in the help file. They are not to be inserted in the function.
Maybe, try something like this: STR ( "%.1m" , anchor_b )
It seems that the "~" flag doesn't works. Maybe this is another specific caracter...
So, you can make a test like this:

IF STR ( "%.1m" , FRA ( anchor_b ) ) = "0.0" THEN m_text = STR ( "%.0m" , anchor_b ) ELSE m_text = STR ( "%.1m" , anchor_b ) 

wizysmart.difraxis.com –––––––––––––––––––––––––––––

Thank you for help but I've changed little bit what you written.

Insted of :
IF STR ( "%.1m" , FRA ( anchor_b ) ) = "0.0" THEN

I've put:

FRA ( anchor_b ) < 0.05 THEN

Because when I was number e.g 14.013 after converting to str the statment STR(0.013)!="0.0" (it isn't equal that's why 0 it is not going to removed) and then 14.013 is rounded to 14.0

Anyway your idea helped me a lot

Hello,

Thank you for your feedback.
Have a look to this:

anchor_b = 14.013
val_str = STR ("%.1m", FRA ( anchor_b ) )
val_fra = FRA ( anchor_b ) 

val_str returns "0.0" and val_fra returns 0.013.
Your solution is working too but I think you confused things somewhere beacause my solution worked without problem.

wizysmart.difraxis.com –––––––––––––––––––––––––––––

1 - 4 (4)
  • 1

https://campus.allplan.com/ uses cookies  -  More information

Accept