Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
My mistake. I only solved my second problem from the previous post.
I'm trying to do a Python script where I want to append an Item from an FBList to another FBList. What I want to happen is, I don't want to prevent appending the same Item in the other FBList once it is already appended. I know how if/else condition works, I just don't know yet how to properly apply it in this case. Here's the sample BTW.
def addHeadCall(control, event):
addOpt = optList.Items[optList.ItemIndex]
headList.Items.append(addOpt)
print addOpt, "has been added to Head"
I'm sorry, I'm still completely new to Python especially for Motionbuilder. I can only apply a few of my knowledge for MEL scripting.
Again, thanks in advance for the help.
Solved! Go to Solution.
Solved by vdebaie. Go to Solution.
Solved it on my own. Thanks anyways
def addHeadCall(control, event):
s = len(headScroll.Items)
addOpt = optList.Items[optList.ItemIndex]
p = (addOpt + " has been added to Head Index")
if s == 0:
headScroll.Items.append(addOpt)
print p
elif 0 < s < 5:
e = 0 #count for existing item
for item in headScroll.Items:
if addOpt == item:
e = e + 1
if e == 0:
headScroll.Items.append(addOpt)
print p
But if there's an alternative way, please inform me. Thanks in advance
would something like this work?
def addHeadCall(control, event):
addOpt = optList.Items[optList.ItemIndex]
if addOpt not in headScroll.Items:
headScroll.Items.append(addOpt)
print (addOpt + " has been added to Head Index")
Can't find what you're looking for? Ask the community or share your knowledge.