-
-
Save nicelifeBS/05fd9ca69d9b1d6508b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
""" Short snippet demonstrating how you can edit scene item's name using MODO 701 Python API. | |
""" | |
import lx | |
import lxu.select | |
PREFIX = 'prefix_' | |
# lxu.select module contains a few useful classes for dealing with selections. | |
# ItemSelection() allows for getting cuurent item selection. | |
# The returned list contains a set of lx.object.Item() interfaces | |
# that give access to MODO scene items. | |
selected_items = lxu.select.ItemSelection().current() | |
for item in selected_items: | |
# We're explicitly casting each item from the list to lx.object.Item(). | |
# This is not really needed because item is lx.object.Item() already but | |
# if you're using editor with autocompletion like Komodo it'll allow your IDE | |
# to present you with a list of available methods for item. | |
# Also easier to remember what type of object item is. | |
item = lx.object.Item(item) | |
# lx.object.Item() contains a set of methods to operate on scene items. | |
# UniqueName() method returns an item's name as you see it in MODO UI. | |
item_name = item.UniqueName() | |
if item_name.startswith(PREFIX): | |
continue | |
item_name = PREFIX + item_name | |
# SetName() simply sets item's name to a string passed as argument. | |
item.SetName(item_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment