Quantcast
Viewing all articles
Browse latest Browse all 5

Answer by John MC for Make points out of faces instead of vertices in geometry nodes

i think this is not possible with the current version of geometry nodes.

But you could do it with the help of this python script:

import bpyimport bmeshfrom mathutils import Vectorprint("*" * 50)obj = bpy.context.objectprevMode = obj.mode# Will need to be in object modebpy.ops.object.mode_set(mode='OBJECT', toggle=False)# Create a bmesh accessbm = bmesh.new()bm.from_mesh( obj.data )# Get faces accessbm.faces.ensure_lookup_table()# Identify the wanted facesfaces = [f for f in bm.faces]faceNormals = [f.normal for f in bm.faces]newVerts = []for eachFace in faces:#    print("new face:")    x = 0    y = 0    z = 0    for eachVertex in eachFace.verts:#        print("vert:",eachVertex.co)        x = eachVertex.co.x + x        y = eachVertex.co.y + y        z = eachVertex.co.z + z    noOfVertsInFace = len(eachFace.verts)    avgX = x / noOfVertsInFace    avgY = y / noOfVertsInFace    avgZ = z / noOfVertsInFace    newVerts.append((avgX, avgY, avgZ))verts = [v for v in bm.verts]       bmesh.ops.delete( bm, geom = faces, context = 'FACES_ONLY' )bmesh.ops.delete( bm, geom = verts)for v in newVerts:    bm.verts.new(v) bm.to_mesh( obj.data )# Back to the initial modebpy.ops.object.mode_set(mode=prevMode, toggle=False)

how can you use it?

  1. select your object which you want to use (better make a copy of it and save that because your original object/mesh will be changed)
  2. run the script
  3. now you can use geometry nodes with that changed object

what does the script?

The script iterates over each face. For each face it iterates over all vertices and calculates the average point ("center").It then deletes all existing faces and vertices and creates vertices at these centers.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>