1
$\begingroup$

When I'm in curve's Edit Mode, I can select curve's points, and I can see its global position in item's Transform. How can I get the global position with python?

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Select the bezier curve object and then run the script which outputs all the curve points in local space and world space.

import bpy

o = bpy.context.object
m = o.matrix_world

for s in o.data.splines:
    for p in s.bezier_points:
        print("point in local space:", p.co)
        print("point in world space:", m @ p.co)
$\endgroup$
4
  • $\begingroup$ thank you very much!! $\endgroup$
    – jokic jo
    Sep 8, 2022 at 9:15
  • $\begingroup$ sure np! can you please mark the checkmark on the left side of my answer (it becomes green after clicking) if your issue is resolved? $\endgroup$ Sep 8, 2022 at 9:19
  • $\begingroup$ on more question, if i have the point's global position ,how can change it to local position? $\endgroup$
    – jokic jo
    Sep 8, 2022 at 9:34
  • $\begingroup$ instead of multiplying by the matrix_world you can multiply by matrix_local to some global points to get their equivalent in local space coords. $\endgroup$ Sep 8, 2022 at 10:10

You must log in to answer this question.

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