3
$\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$
2
  • $\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, 2017 at 16:52
  • $\begingroup$ Always check the system console for errors. NameError: name 'cos' is not defined $\endgroup$
    – batFINGER
    Nov 12, 2017 at 16:59

1 Answer 1

2
$\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).

$\endgroup$
3
  • $\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$ Nov 13, 2017 at 21:56
  • $\begingroup$ Then at least upvote it and accept it as answer. $\endgroup$
    – dr. Sybren
    Nov 19, 2017 at 11:02
  • 1
    $\begingroup$ Sorry for my ignorance. Answer accepted with pleasure. $\endgroup$ Nov 20, 2017 at 23:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .