Getting another list, but using a list as a index of which parts to grab off a list,

Ok so, here is the script -Note this is not a running script, it is half way coded

I need to use PolyProps and while genrating a list PolyProperties- that is all items on the list that contain “FaceProp_” (I have this part)
I need it to get the corresponding Property value to the property and put it in a list PolyValue in the same order as PolyProps

list - [blah, blah, blah, FaceProp_01, FaceProp_02]
values- [Blah, blah, blah, “Empty”,“Empty”]

the script I need to write, will turn this into

  • polyProps = object.getPropertyNames()
  • polyProperties =[]
  • PolyValues =[]
  • x=0
  • for item in polyProps:
  •     <b>if</b> 'FaceProp' <b>in</b> item:
  •         polyProperties.append(item)

I know I am close…

edited above bump

Sounds like a job for a dictionary. If you need to, you can make a dictionary from two lists using the zip() method.

listA = [1, 2, 3]
listB = ['a', 'b', 'c']

myDict = dict(zip(listA, listB))

You can then get values corresponding to keys in a list using the following:

keyList= [2, 3]
valueList = [myDict[key] for key in keyList]

I’m not sure about this, but since its already a list of the objects properties, or polyProperties, you should just be able to use the list item to get the polyProperty Values.

if polyProperties[4] &gt; 2:
    do something

I’m pretty sure you can do that.

the problem is I need the keys to be generated by making the list PolyProps,

polyProps = object.getPropertyNames()
polyProperties =[]
PolyValues =[]
for item in polyProps:
if ‘FaceProp’ in item:

This will not work?

PolyProps should be renamed

ObjProps = object.getPropertyNames()

Then I use

  • polyProperties =[]
  • <b>for</b> item <b>in</b> polyProps:
  •     <b>if</b> 'FaceProperty' <b>in</b> item:
  •         polyProperties.append(item)

I was thinking that I might be able to do this

  • X=0
  • polyProperties =[]
  • polyValues = []
  • for item in polyProps:
  • if ‘FaceProperty’ in item:
  •       polyValues.append(X)
  •       X=X+1
  •       polyProperties.append(item)

If your just assigning the value of x then yes, that should work.

I need to grab part X of the list, not input X as the data,

polyValues.append(polyprops piece number X)

what is the syntax to grab number X piece of a list?

Do you want x to be the index number of the list?
EDIT: Sorry, yes for index numbers that should work.

ok let me upload the next iteration :slight_smile: