Python - How do I leave out an optional parameter in a class

Im trying to use create_mesh_section class from this page in the unreal python docs.

I can provide every parameter for the class apart from the vertex_colors parameter but it says that it is optional.

When I run the code an error message appears saying it is required.

any fixes?

Line of code:

mesh.create_mesh_section(0, verts, triangles, normals, UV, tangents=tangents, create_collision=False)

Error message:

LogPython: Error: TypeError: create_mesh_section() required argument 'vertex_colors' (pos 6) not found

Extract from docs about the class I’m using

create_mesh_section (section_index, vertices, triangles, normals, uv0, vertex_colors, tangents, create_collision ) → None

Create/replace a section for this procedural mesh component. This function is deprecated for Blueprints because it uses the unsupported ‘Color’ type. Use new ‘Create Mesh Section’ function which uses LinearColor instead. deprecated: This function is deprecated for Blueprints because it uses the unsupported ‘Color’ type. Use new ‘Create Mesh Section’ function which uses LinearColor instead.

Parameters

  • section_index (int32) – Index of the section to create or replace.
  • vertices (Array( Vector)) – Vertex buffer of all vertex positions to use for this mesh section.
  • triangles (Array( int32 )) – Index buffer indicating which vertices make up each triangle. Length must be a multiple of 3.
  • normals (Array( Vector)) – Optional array of normal vectors for each vertex. If supplied, must be same length as Vertices array.
  • uv0 (Array( Vector2D)) – Optional array of texture co-ordinates for each vertex. If supplied, must be same length as Vertices array.
  • vertex_colors (Array( Color)) – Optional array of colors for each vertex. If supplied, must be same length as Vertices array.
  • tangents (Array( ProcMeshTangent)) – Optional array of tangent vector for each vertex. If supplied, must be same length as Vertices array.
  • create_collision (bool) – Indicates whether collision should be created for this section. This adds significant cost.

By optional they actually mean that you can pass an empty array, but the parameter itself is not optional due to the way the automatic python binding works.

1 Like