APEX Script: Get component of Vector

   978   2   0
User Avatar
Member
25 posts
Joined: 11月 2018
オフライン
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)
Edited by playBlaster - 2024年8月16日 20:20:03
User Avatar
Member
30 posts
Joined: 5月 2015
オフライン
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)
Edited by NMVHS - 2024年8月17日 04:42:06
User Avatar
Member
25 posts
Joined: 11月 2018
オフライン
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
  • Quick Links