kopia lustrzana https://github.com/vilemduha/blendercam
added active to shapely Poly and active to coords
rodzic
2fb9a15220
commit
abd971aa66
|
@ -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
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue