Search - User list
Full Version: APEX Script: Get component of Vector
Root » Rigging » APEX Script: Get component of Vector
playBlaster
Is there an easy python like way to get a component of a vector in APEX Script without having to add nodes and use the API to connect ins and outs?

For example, the following code gives an error

pos = Vector3(1, 0, 0)
x = Float(pos.x)

The error is:

(Error: Error generated by Python node.
Line 2: :: x = Float(``pos.x)``
Can only fetch attributes from graph or node objects).

It would seem like something as simple as grabbing a component of a vector could be done without getting too verbose.

(fwiw,
pos[0]
nor
pos.x()
work either)
NMVHS
Correct me if I'm wrong... I think apex snippet is not exactly python. Each function has a corresponding apex node. You would need vector3ToFloat node to split a vector, thus you'll need to use vector3ToFloat() in snippet.

pos = Vector3(1,0,0)
x, y, z = vector3ToFloat(pos)
playBlaster
NMVHS
x, y, z = vector3ToFloat(pos)

That's just what i needed NMVHS! And yeah, i know APEX script is not exactly python, that's why i said "python like". What threw me off though was the "x, y, z =" syntax. Mmmm, i see destructuring. I'm rather new to python but I'm familiar with this from javascript, which was only added fairly recently. I'll keep this in mind when faced with similar issues.

Thanks,
Sky
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB