DIESEL expression - If Statement in a Field

DIESEL expression - If Statement in a Field

Julio_Soto
Advisor Advisor
495 Views
2 Replies
Message 1 of 3

DIESEL expression - If Statement in a Field

Julio_Soto
Advisor
Advisor

I'm trying to create a field in an attribute that will take the value of a Rotation Parameter and subtract 180 from it, multiplying it by (-1) if the value is greater than 180. This way I can get negative angle values.

 

I thought this might work

 

$(if, $(>, Angle1,180), ((Angle1-180)*-1)),Angle1)

 

but no luck. Is this possible?

0 Likes
496 Views
2 Replies
Replies (2)
Message 2 of 3

s_hendrikxHMCCF
Advocate
Advocate

 

$(if,$(>=,$(getvar,Rotation),180),$(*,-1,$(-,$(getvar,Rotation),180)),$(-,$(getvar,Rotation),180))

 

  • $(getvar,Rotation): Retrieves the value of the rotation parameter.
  • $(>=,$(getvar,Rotation),180): Checks if the rotation value is greater than or equal to 180.
  • $(-,$(getvar,Rotation),180): Subtracts 180 from the rotation value.
  • $(*,-1,$(-,$(getvar,Rotation),180)): If the rotation value is greater than or equal to 180, multiply the result by -1.
  • $(if,condition,expr_true,expr_false): The if function evaluates the condition and returns expr_true if the condition is true, otherwise, it returns expr_false.

Maybe this will help

 

0 Likes
Message 3 of 3

vladimir_michl
Advisor
Advisor

No, you cannot use (getvar) for this. Looks like an AI-generated response...

It is not possible to use conditional expressions but you can trick it by using a "magic" math expression in the field. See the tip https://www.cadforum.cz/en/if-statement-in-autocad-text-fields-and-attributes-tip14215 to get something like that:

 

Vladimir Michl, www.arkance.world  -  www.cadforum.cz

 

0 Likes