added active to shapely Poly and active to coords

pull/200/head
palain 2022-01-16 10:47:08 -04:00
rodzic 2fb9a15220
commit abd971aa66
1 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -25,6 +25,7 @@ import bpy
import mathutils
from mathutils import *
from math import *
from shapely.geometry import Point, LineString, Polygon, MultiLineString
def tuple_add(t, t1): # add two tuples as Vectors
@ -317,3 +318,20 @@ def addBoundRectangle(xmin, ymin, xmax, ymax, name='bounds_rectangle'):
activeName(name)
def activeToCoords():
bpy.ops.object.duplicate()
obj = bpy.context.active_object
bpy.ops.object.convert(target='MESH')
activeName("_temp_mesh")
coords = []
for v in obj.data.vertices: # extract X,Y coordinates from the vertices data
coords.append((v.co.x, v.co.y))
removeMultiple('_tmp_mesh')
return coords
def activeToShapelyPoly():
return Polygon(activeToCoords()) # convert coordinates to shapely Polygon datastructure