Skip to content

Instantly share code, notes, and snippets.

@SuddenDevelopment
Created April 1, 2023 17:39
Show Gist options
  • Save SuddenDevelopment/e5b076329043e937b71c790e0628bcd9 to your computer and use it in GitHub Desktop.
Save SuddenDevelopment/e5b076329043e937b71c790e0628bcd9 to your computer and use it in GitHub Desktop.
blender object 2d profile object python
def objTo2DProfile(obj, strName=None, strPosition="ORIGIN"):
if strName == None:
strName = f'{obj.name}_profile'
arrVerts = []
arrPolyVerts = []
for vert in obj.data.vertices:
arrVerts.append((vert.co.x, vert.co.y))
arrVertIndices = mathutils.geometry.convex_hull_2d(arrVerts)
for intVert in arrVertIndices:
arrPolyVerts.append([arrVerts[intVert][0], arrVerts[intVert][1], 0])
objNew = createMesh2D(arrPolyVerts, strName)
if strPosition == 'TOP':
arrTopLocation = getOriginLocation(obj, 2, '+')
setLocation(objNew, (0, 0, arrTopLocation[2]))
return objNew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment