Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Scripting curiosum?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
399 Views, 3 Replies

Scripting curiosum?

Hi,

 

I have been working on a script, and I ran into yet another scripting curiosum (for me at least).

 

I made this little test to show...

scripting test.PNGscript.PNG

 

 

 

 

 

 

 

 

 

 

 

 

Now if I do my math correctly, I would expect the result to be 108 (9*12) but instead it comes to 918 (9*102)?

It of course has to do with line 10 in my script, where I expected distance to become 12 (the value of item.TAL_2 + 2) not 102??

 

I tried changing the script so I could run it as a normal Javascript in Chrome, and here it comes out with 108 - so what am I missing?

 

Best regards from Denmark

 

Kasper  

 

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

The distance is coming in as a string. This code:

 distance + 2

is concatenating "2" to the string "10", thus "102". What you need to do is convert distance to an integer. You should be able to say

distance = Number(distance);

at the top of the function to fix this. You might want to do the same to the speed variable just in case.

 

 

Here's a little explanation I did in a firefox console

 

acad help.PNG

 

 

 

Message 3 of 4
Anonymous
in reply to: Anonymous

Thank's for the reply...

 

You were almost right 😉

regneeksempel.JPG

 

 

 

 

 

 

 

 

 

 

 

 

Now it works....

 

Kasper

Message 4 of 4
Anonymous
in reply to: Anonymous

I was right 😉

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

Post to forums  

Autodesk Design & Make Report