This file contains 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
# Python API example for skin weight access | |
# Place this file into an lxserv folder | |
# | |
# Creates a command that takes the names of a mesh and a connected joint locator and inverts the weight values | |
# | |
# Example command usage: | |
# example.printJointWeights locator:"Skeleton_Joint (4)" mesh:MyCube | |
import lx | |
import lxu |
This file contains 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
# There is no dedicated methods for the selection sets in the TD SDK as of yet. | |
# Currently you can only create pickMaps for vertices using the vmaps methods. | |
import modo | |
# Create a sphere | |
lx.eval('script.implicit "Unit Sphere Item"') | |
mesh = modo.Mesh('Sphere') | |
This file contains 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
# 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) |
This file contains 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
# Example of finding materials connected to a mesh. This should become redundant as | |
# there will be convenience functions added to the TD SDK soon. | |
import modo | |
# This gets the selected mesh if any | |
mesh = modo.Mesh() | |
if mesh: | |
This file contains 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
import modo | |
# By not passing an item when initializing the Mesh object, | |
# it will use the selected if any | |
curve = modo.Mesh() | |
# Iterate the curve polygons and activate the endpoints | |
for polygon in curve.geometry.polygons.iterCurves(): | |
polygon.accessor.SetFirstIsControlEndpoint(1) | |
polygon.accessor.SetLastIsControlEndpoint(1) |
This file contains 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
''' | |
This command sets or gets the 'Start Control' or 'End Control' state of a curve (not a bezier curve). | |
# Example for querying the Start Control state for every curve polygon found in the selected mesh: | |
import modo | |
mesh = modo.Mesh() | |
for curvePolygonIndex in [i.index for i in mesh.geometry.polygons.iterCurves()]: | |
startControl = lx.eval('curve.endPoints polyIndex:{0} first:?'.format( curvePolygonIndex )) | |
lx.out(startControl) |
This file contains 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
import modo | |
scene = modo.Scene() | |
# Add a channel set group and select it, so it will display | |
channelSet = scene.addGroup( name='MyChannelSet', gtype='chanset') | |
# Create locator and add some channel to the channel set | |
loc = scene.addItem(modo.c.LOCATOR_TYPE) |
This file contains 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
"""Example command to read or write item tags | |
Example usage: | |
item.editTag sunLight013 TAGN "Test" | |
item.editTag sunLight013 TAGN ? | |
import modo | |
item = modo.Item('Directional Light') | |
value = 'Test' |
This file contains 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
# Test is a given point is visible in the camera | |
# Convert between 3d and screen coordinates | |
import modo | |
# Assuming the camera is also the active view | |
def pointInCamera(cam, position): | |
aperture_x = cam.channel(lx.symbol.sICHAN_CAMERA_APERTUREX).get() | |
aperture_y = cam.channel(lx.symbol.sICHAN_CAMERA_APERTUREY).get() |
This file contains 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
""" | |
Example command for removing zero rotations from a locator item. | |
Clears the zero rotation offset while maintaining the pose. Acts on all selected locator items. | |
Limitation: Only works if the rotation item's location is subsequent to the zero rotation item | |
(As by default when using the skeleton tool) | |
Existing animation curves are removed | |
Simplified example, no argument handling or command helps/configs added. |
OlderNewer