Can't square a user defined parameter

Can't square a user defined parameter

jonrbloom
Advocate Advocate
5,727 Views
14 Replies
Message 1 of 15

Can't square a user defined parameter

jonrbloom
Advocate
Advocate

I'm trying to set a parameter within the Modify->Change Parameters dialog to the diagonal of a square.

The width/height of the square is defined by a User Parameter, "Width".

 

So, the Expression should be:

    sqrt(pow(Width;2)*2)

or

    sqrt(Width*Width*2)

 

But the program won't let me square "Width", however I try and write it.

 

Replacing Width with its defined value (in this case 50), works just fine:

    pow(50;2) and (50*50) and even (Width * 50) are all fine

But

    pow(Width;2) and (Width*Width) are both rejected - The expression stays red and I can't exit the dialog

 

Is this expected behaviour ?

 

0 Likes
5,728 Views
14 Replies
Replies (14)
Message 2 of 15

innovatenate
Autodesk Support
Autodesk Support

 

Thanks for posting. I believe the issue is that due to the Units being used in the function.

 

You should first eliminate the unit. For example 50 mm * 1 ul/1mm = 50 ul

 

See the screenshot below for reference. I'm doing the square root of the sum of the squares for Length and Width. You'll note at the end Fusion will add a *1mm to add the unit back in for you.

 

 

Unitless Parameter for Function in Fusion 360.PNG

 

 

Does that help?

 

Thanks,

 

 




Nathan Chandler
Principal Specialist
Message 3 of 15

jonrbloom
Advocate
Advocate
Thank you, this was very helpful.

I simplified your original suggestion slightly, to:

sqrt(pow(Width/mm,2)*2)*1mm

which worked perfectly.

I do think this a bit counter-intuitive - If the program supported sqmm (and I guess sqinch) as units, the more obvious formula would have worked, since the pow would generate sqmm, and the sqrt would bring the units back to mm again. Admittedly, this would just create a problem when someone tried similar calculations with sqmm, but such formulas would be more common with linear units than areas.

But now that I understand what's going on it's no great problem.

Thank you very much for the help.
0 Likes
Message 4 of 15

jake.mcivor
Participant
Participant

I know this old, but it's the first post that came up when I searched. Not sure if it is my location or an update, but the syntax for functions has changed, leading to much confusion.


Using a semi-colon to separate arguments instead of a comma did the trick:


sqrt(pow(Width/mm;2)*2)*1mm

0 Likes
Message 5 of 15

Anonymous
Not applicable

Hi there. Im still struggling with this. Im trying to find the long side of a basic triangle in a parametric formula but have no idea how to write it. Its simply sqrt(a^2+b^2)=c,  however im not sure how to word it correctly so fusion can read it. I believe it is again an issue with units as when I enter the value the parameter I use for a and c is representing the calculation works however when I put the name of the parameter in the calc instead it does not work. What does ul mean? Is there a table of commands for parameter calculations? Ie square root, square etc?

 

Many thanks!

0 Likes
Message 6 of 15

beananimal
Advocate
Advocate

Hey Autodesk....

 

How about making parameter math make sense instead of it being a half baked after thought?  You guys are really good at getting stuff barely useable... why not try harder to make things work as expected?

Message 7 of 15

jonrbloom
Advocate
Advocate

I guess once you understand that everything has units it becomes clear that this is hard to do automagically, while humans (once they have learned this nuance), can do so fairly easily. It isn't impossible to fix though - If you impose the rule that mixing of units is never permitted, it simplifies the problem to tracking the underlying unit and the power, and feeding in the rules for each operator. Then 5mm*5mm*5mm becomes (5*5*5)*(mm;power3), and sqrt removes one unit of power in addition to calculating the real value. I'm guessing that a change like this now would ripple through large quantities of Fusion360 code though, and likely there are more important (revenue making) changes to focus on.

 

I agree it's a little clunky and counterintuitive though, and I don't recall seeing anything in the docs to explain that the arguments to sqrt must be unitless. A more complete tutorial would perhaps be a good investment by the Fusion 360 team.

Message 8 of 15

g-andresen
Consultant
Consultant

Hi,

In this forum, it is customary to describe a fact even when criticizing.
Unfortunately, there is no such description in your post.

 

günther

0 Likes
Message 9 of 15

beananimal
Advocate
Advocate

The workaround I came up with is to simply multiply EACH parameter by 1 to strip its units.

sqrt( (1 * parameter) + (1 * parameter) )  for example. It works - but is messy.

 

IMHO the inclusion of units in maths is too complicated to implement easily - 2in X 2mm makes sense, but somewhere behind the scenes somebody has to write the conversion logic.. There are simply far too many possibilities to cover. 

I think unit-less formula math makes more sense.... easy to explain and force the user to make any conversions using --- ummm basic math.

I guess there is no easy answer here - you are correct, it should at least be better documented - including the (1 times param) workaround.

Grumpiness? - Just started heavily using this product for two projects, and as I have stated several times in the past. Each time I use it, I find more frustrating quirks and design choices. Products are supposed to feel better as you accumulate experience. This product poses a new frustration at every turn and often feels very unpolished for as powerful as it is.

0 Likes
Message 10 of 15

beananimal
Advocate
Advocate

Respectfully Gunther...

 

It also appears customary in this forum for you and a certain self proclaimed whisperer to regularly ignore context in favor of taking pot shots at frustrated posters, most often without even attempting to help.


0 Likes
Message 11 of 15

jonrbloom
Advocate
Advocate

Yeah - I wasn't promoting the complete tracking of units. Just musing how I might do it (I'm a s/w engineer), and acknowledging that it's hard to make these operators 'just work' because Fusion already ties units into every parameter, and changing that now would not be practical. That means either Fusion somehow deals with them in a more intuitive way (which is non-trivial), or we accept the limitation and manually remove the units.

 

Better math docs, in an easily searchable location (not buried in a forum post) please Autodesk 🙂

 

0 Likes
Message 12 of 15

beananimal
Advocate
Advocate

I suppose the  (1 * param) workaround will suit my needs.

 

I honestly don't see AD addressing this in any fashion from changes to documenting it any differently.  I mean (honestly) they are putting resources toward things like facebook forum integration....  

 

The parameters feature is certainly powerful - it is a shame it is not more polished... including import/export sticky windows - the ability to assign to sliders. Etc. 

0 Likes
Message 13 of 15

joshuahume1
Explorer
Explorer

Is it too late to revive this thread?  Or should I create a new topic?  I'm having this exact issue, and none of the workarounds posted seem to be helping.

 

I'm trying to create a short staircase that adjusts parametrically based on the rise, run, and quantity of rises, like this:

Screen Shot 2022-05-05 at 11.44.53 AM.png

 

The goal is to get a parameter into the Distance field, so the whole thing changes correctly.  Currently if I change the rise or the run, then I have to manually type in the Distance.

 

My parameters are:

rise = 8"

run = 10"

rise_quantity = 5

rr_spacing = sqrt( (rise ^2) + (run ^2) )

 

However, no matter what I try, I can't seem to get that rr_spacing value to compute properly.  It just stays red when I enter it into the value field on the user defined parameter box.  I've tried all the work arounds I can find, to no avail.

 

I've no doubt this is very easy and obvious, but I seem to be stumped!  Any help would be very much appreciated.

 

0 Likes
Message 14 of 15

g-andresen
Consultant
Consultant

Hi,

Fusion doesn´t know mm². > create your squareroot unitless!

unitless_.png

günther

Message 15 of 15

joshuahume1
Explorer
Explorer

That worked!  Thanks very much!  

0 Likes