Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Subassembly Composer Change Sign Of A Slope

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
viktors.zilinskis
1639 Views, 6 Replies

Subassembly Composer Change Sign Of A Slope

Hello!

 

I have an Input parameter called "Construction Slope" of type "Slope" that I would always like to be negative. As i did not find the possibility to restrict end user to inputing only negative value I tried to change the sign of the slope to negative if it is positive  by using an "IF" expression (when used as a "Geometry Property" for a new link):

 

IF(ConstructionSlope<=0,ConstructionSlope,(-1)*ConstructionSlope)

 However this expression produces an error: "Compiler error(s) encountered processing expression <...> Cannot infer a common type because more than one type is possible". If i remove multiplication by -1 then the error is gone (and the whole expression becomes meaningless as well of course). See even attached image. Any ideas about how to fix this one would be apprecciated!

 

BR,

Viktors

 

6 REPLIES 6
Message 2 of 7

I found a workaround actually:

 

IF(ConstructionSlope<=0,1*ConstructionSlope,(-1)*ConstructionSlope)

Seems like if a slope variable is multiplied by a number then i becomes something else (another type of variable). So if I multiply even the first argument by 1, the problem is gone (both arguments become of the same type as both of them are multiplied by a number). I am not sure my explanation is quite correct but it seems to work at least.

Message 3 of 7
fcernst
in reply to: viktors.zilinskis

-math.abs(ConstructionSlope)



Fred Ernst, PE
C3D 2024
Ernst Engineering
www.ernstengineering.com
Message 4 of 7
viktors.zilinskis
in reply to: fcernst

simplier and also works, thanks!

Message 5 of 7

I find multiplying by 1 better as it doesn't tweak positive/negative unlike math.abs(ConstructionSlope)

Message 6 of 7

Thank you for this post !

I was having headaches today

--------------------------------------------
Using : Autodesk Civil 3D 2022& 2023
AKA Frank Freitas, Senior Roadway Designer @ Kiewit
Message 7 of 7

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report