TransWikia.com

How can I calculate global coordinates for GPencilStrokePoint in Blender 2.8 and Python?

Blender Asked by user82670 on November 19, 2021

I have already tried by calculating:

point_global_co = grease_pencil_object.matrix_world @ point.co

But it gives very odd results.

One Answer

The following script prints the global point coordinates for every grease pencil object in the scene. The coordinates seem to be accurate, judging from basic tests.

import bpy


for obj in bpy.data.objects:
    if obj.type == "GPENCIL":
        print(f"n{obj.name}")
        for layer in obj.data.layers:
            for frame in layer.frames:
                for stroke in frame.strokes:
                    for point in stroke.points:
                        print(obj.matrix_world @ point.co)

Answered by Robert Gützkow on November 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP