I would like to be able to extract start and end points of grease pencil
line tool, the one used for annotations in 2.80.
It would be great if I can get the data in 3d view and 2d screen view in Python.
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Grease Pencil (GP) data structure is like this:
GP-Object --> GP-Layers --> GP-Frames --> GP-Strokes --> GP-Stroke-Points
Now, the python commands to get different GP-data,
#1) To get the GP-Object data GPObj = bpy.data.objects['GP Object Name'].data #2) To get the GP-layers, use layer name or index. GPLyr = GPObj.layers['Layer Name'] #3) To get the GP-Frames, use index. But there are other properties of the layer # you can access e.g., opacity, thickness, select, etc. You can add or remove the frame. GPFrm = GPLyr.frames #4) To get the GP-strokes, use index. You can add or remove a stroke, change the # display-mode, line-width, material index, etc. GPStk = GPFrm.strokes #5) To get the GP-points, you can use the index to get individual points. # You can add or remove points. GPPts = GPStk.points
and each point has info about the location, pressure, strength, uv-rotation, etc. With the help of "foreach_get()" function, you can get the location (or pressure, strength, uv-rotation) of all the points.
#6) To get the location of single GP-point loc = GPPts.co
Use the grease pencil API:
Drill down through the layers and frames and strokes to get to the points: