how to add a face between two planes in a mesh?

how to add a face between two planes in a mesh?

alikims
Explorer Explorer
258 Views
2 Replies
Message 1 of 3

how to add a face between two planes in a mesh?

alikims
Explorer
Explorer

I have a mesh made out of two planes stacked on top each other, and I want to create a new vertical face between these planes.

 

maya_face.png

 

I selected 4 vertices, two on the top plane, two on the bottom one, in the counter-clockwise order. I wrote a python script that will create a new face, that will be added to the mesh, based on the selection, but it produces an error:

select -cl  ;
select -r pPlane3.vtx[151] ;
select -tgl pPlane3.vtx[162] ;
select -tgl pPlane3.vtx[41] ;
select -tgl pPlane3.vtx[30] ;

import maya.cmds as cmds

def create_face_from_selected_vertices():
    # Get selected vertices
    selected_verts = cmds.ls(selection=True, flatten=True)
    
    # Verify we have exactly 4 vertices selected
    if len(selected_verts) != 4:
        cmds.warning("Please select exactly 4 vertices (2 from top plane, 2 from bottom plane)")
        return
    
    try:
        # Get the mesh name from the first selected vertex
        mesh_name = selected_verts[0].split('.')[0]
        
        # Get the vertex indices (the numbers after "vtx[" in the vertex names)
        vert_pos = []
        for v in selected_verts:
            # Extract the vertex index from the name (e.g., "pPlane1.vtx[2]" -> 2)
            #index = int(v.split('[')[-1].rstrip(']'))
            #vert_indices.append(index)
            vert_pos.append(cmds.pointPosition(v))
        
        print(vert_pos)
        
        # Create a new face using polyAppend with the append flag
        cmds.polyAppend(
            mesh_name,
            append=vert_pos,
            constructionHistory=True
        )
        
        # Print success message
        print("Successfully created new face between selected vertices")
        
    except Exception as e:
        cmds.warning(f"Error creating face: {str(e)}")

# Execute the function
create_face_from_selected_vertices()
[[0.30000001192092896, 0.0, 0.30000001192092896], [0.30000001192092896, 0.0, 0.19999998807907104], [0.30000001192092896, 0.19127875566482544, 0.30000001192092896], [0.30000001192092896, 0.19127875566482544, 0.19999998807907104]]
# Warning: Error creating face: Need at least one "-ed" flag (edge number).

 

the documentation says that -ed flag should be avoided in Python, how to make this work?

 

0 Likes
259 Views
2 Replies
  • of
Replies (2)
Message 2 of 3

Christoph_Schaedl
Mentor
Mentor

If i see that correct you are trying to create non manifold geo.
You cant extrude an edge from the midde of a plane.

----------------------------------------------------------------
https://linktr.ee/cg_oglu
0 Likes
Message 3 of 3

mcginnc
Autodesk
Autodesk

Perhaps Combine them and use the Bridge tool on the edge



Catherine McGinnis
Maya Quality Assurance
0 Likes