Skip to content

Instantly share code, notes, and snippets.

@ivogrig
Created July 15, 2015 10:14
Show Gist options
  • Save ivogrig/801ef65e71b85cd58e81 to your computer and use it in GitHub Desktop.
Save ivogrig/801ef65e71b85cd58e81 to your computer and use it in GitHub Desktop.
Example of creating a mesh and adding a vertex using Modo's Python API
# Example of creating a mesh and adding a vertex using Modo's Python API
import lxu
# Get current scene
scene = lxu.select.SceneSelection().current()
# Create new mesh item
scene_service = lx.service.Scene()
mesh_type = scene_service.ItemTypeLookup(lx.symbol.sTYPE_MESH)
mesh_item = scene.ItemAdd(mesh_type)
# Get mesh object
chanWrite = lx.object.ChannelWrite(scene.Channels(lx.symbol.s_ACTIONLAYER_SETUP, 0))
write_mesh_obj = chanWrite.ValueObj(mesh_item, mesh_item.ChannelLookup(lx.symbol.sICHAN_MESH_MESH))
mesh = lx.object.Mesh(write_mesh_obj)
# Add a point using the PointAccessor interface
pointAccessor = mesh.PointAccessor()
position = (1,2,3)
newPointID = pointAccessor.New(position)
# Update the mesh
mesh.SetMeshEdits(lx.symbol.f_MESHEDIT_POINTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment