Script node imports

Hey @mati-nvidia,

I’m working thru the mesh problem, more to come on that I’m sure!

But I wanted to ask about using imports in the script node.

I’m trying to import “math”, error is flagged as undefined. Works fine in vscode, I’m thinking I’m importing in the wrong place or do I need to add the math module somewhere else in OV?

Thanks again,

Code below

import math
pi = math.pi

def PointsInCircum(r,n=100):
return [(math.cos(2pi/nx)r,math.sin(2pi/n*x)*r) for x in range(0,n+1)]

a = PointsInCircum(10)

db.outputs.points = a

Hi @Sirens_uk. This has been completely overhauled and works in Create-2022.3 and Code-2022.3. I highly recommend moving to Create right now. As a work around on older versions, you can just stuff your imports in the function(s) that need them.

1 Like

Just to follow up on this, I take it the script node is now the slang node?

I cant seem to find it, when I’ve looked into the slang docs I cant see support for python?

Is this the case?


Slang is a shading language. The Python script node off by default for this Create version. You’ll need to enable it:

Thank you for the clarification.

1 Like

hey @mati-nvidia,

Looks like I have almost everything working, just wondering about the

compute(db) not defined warning. is there another line of code I need to add here?

cheers fella

With the new script node, you really want to define a function called compute. That sort of serves as a “main” function for the node. When you create a new script node, you should see some boiler plate that explains it:

1 Like

had a play, still figuring it out.

I must admit the performance improvement in fps is notable overall. I’m liking the feel of it.

Bravo to the team on that one!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.