Difference between revisions of "Sample Addons"

From Light Forge Wiki
Jump to: navigation, search
(Select Children)
(Select Children)
Line 4: Line 4:
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 +
#called when the addon is selected in the addon's menu
 
def onExecute():
 
def onExecute():
 
#get list of selected groups
 
#get list of selected groups
Line 11: Line 12:
 
for group in groupList:
 
for group in groupList:
 
selectChildren(group)
 
selectChildren(group)
+
 
 +
#select all the children for a given group
 
def selectChildren(groupPath):
 
def selectChildren(groupPath):
 
childCount = api.groups.getChildCount(groupPath)
 
childCount = api.groups.getChildCount(groupPath)
Line 18: Line 20:
 
api.groups.deselectGroup(groupPath)
 
api.groups.deselectGroup(groupPath)
 
 
for i in range(0, childCount):
+
for i in range(0, childCount):
#build the group path for the next group
+
#build the group path for the next group
newPath = groupPath
+
newPath = groupPath
if len(newPath) == 0:
+
if len(newPath) == 0:
newPath = str(i)
+
newPath = str(i)
else:
+
else:
newPath = newPath + "," + str(i)  
+
newPath = newPath + "," + str(i)  
+
api.groups.selectGroup(newPath)
+
api.groups.selectGroup(newPath)
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 19:26, 9 May 2013

Select Children

This script will get a list of all the groups that you currently have selected and then it will select all of their child groups and deselect the parent.

#called when the addon is selected in the addon's menu
def onExecute():
	#get list of selected groups
	groupList = api.groups.getSelectedGroups()
 
	if groupList != None:
		for group in groupList:
			selectChildren(group)
 
#select all the children for a given group			
def selectChildren(groupPath):
	childCount = api.groups.getChildCount(groupPath)
 
	if childCount > 0:
		api.groups.deselectGroup(groupPath)
 
		for i in range(0, childCount):
			#build the group path for the next group
			newPath = groupPath
			if len(newPath) == 0:
				newPath = str(i)
			else:
				newPath = newPath + "," + str(i) 
 
			api.groups.selectGroup(newPath)
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox