1
$\begingroup$

My problem is this: I try and run the script in Blender's text editor and the script fails to math functions, cos() does not work. Failing script within text editor

When I run the same code in Blender's Python console my pasting it directly, there is no problem Same code successfully run by pasting into Python console What is the reason / how to get it work from the Text Editor?

$\endgroup$
  • $\begingroup$ You need to either use the math namespace because you've imported it eg math.cos(angle) or to use directly, from math import cos. For convenience sake the math and mathutils methods have been imported for you in the console. from math import * (See banner message). $\endgroup$ – batFINGER Nov 12 '17 at 16:52
  • $\begingroup$ Always check the system console for errors. NameError: name 'cos' is not defined $\endgroup$ – batFINGER Nov 12 '17 at 16:59
0
$\begingroup$

Answered by @batFINGER in a comment: You need to either use the math namespace because you've imported it eg math.cos(angle) or to use directly, from math import cos. For convenience sake the math and mathutils methods have been imported for you in the console. from math import * (See banner message).

| improve this answer | |
$\endgroup$
  • $\begingroup$ The information in the answers turned out to be useful. I could deduce the syntax at least for the math functions I needed. Now the script works technically. Only thing left is to make it work logically :) $\endgroup$ – Jouko Hahkio Nov 13 '17 at 21:56
  • $\begingroup$ Then at least upvote it and accept it as answer. $\endgroup$ – dr. Sybren Nov 19 '17 at 11:02
  • 1
    $\begingroup$ Sorry for my ignorance. Answer accepted with pleasure. $\endgroup$ – Jouko Hahkio Nov 20 '17 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.