Created
April 1, 2023 17:39
-
-
Save SuddenDevelopment/e5b076329043e937b71c790e0628bcd9 to your computer and use it in GitHub Desktop.
blender object 2d profile object python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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