Hi,
In the screenshot, please have a look at the different results at the two red arrows.
Why is the first code block returning a value and the second codeblock returning null?
Both seem to be executing the same line of code?
Is there a mistake in the definition code block?
definition code underneath
def check (X,Y,T){
return = [Imperative]{
if(T){
if(Y>0){
return = Math.Atan(X/Y)+180;
}
else{
return = Math.Atan(X/Y);
};
}
else {
if(Y>0){
return = Math.Atan(X/Y)+90;
}
else{
return = Math.Atan(X/Y)-90;
};
}
}
};
Hello Jnoordzij,
I’ve copied your code through and it appears to be working for me with a test case. Is this still failing for you?
1 Like
what version of Dynamo is this @jnoordzij - you’re likely hitting a bug that was fixed with namespaced functions in imperative blocks.
I believe it was fixed in 2.1
you can use a workaround like
func = math.Atan;
[imperative]
then inside the imperative block
use func instead of math.Atan.
4 Likes
Thanks guys. I’ll give that a try.
Using Dynamo 2.0.3 by the way.
1 Like
Hello guys,
I tried defining a function outside the imperative block, as you suggested. But I’m still getting None.
I will try upgrading to 2.1.
*Edit: I see that there exists no Dynamo Revit version newer to the 2.0.3 that I’m using now.
So I guess upgrading is not a real option.
What version of Dynamo are you using @solamour?
Does upgrading Dynamo Core to 2.1 also fix this issue for Dynamo Revit 2.0.3?
I tried upgrading to 2.1 but I ran into another issue, posted here, maybe you can help me with that?
@Michael_Kirschner2 maybe you can have a look as well?
I’m using Dynamo Sandbox 2.2.0.4667 right now. You can read more about how to get this on the blog: https://dynamobim.org/a-new-way-to-get-dynamo-sandbox/
Mike’s suggestion was as follows - embedding func inside the Definition, but outside of the Imperative section. This is a workaround to a bug that exists and is on our radar:
def check (X,Y,T){
func = Math.Atan;
return = [Imperative]{
if(T){
if(Y>0){
return = func(X/Y)+180;
}
else{
return = func(X/Y);
};
}
else {
if(Y>0){
return = func(X/Y)+90;
}
else{
return = func(X/Y)-90;
};
}
}
};
1 Like