On 21/06/2018 at 01:52, xxxxxxxx wrote:
Hi all. I am novice in phyton and the scripting too. I want to ask for advice
I have Phyton generator and linked user data - source geometry and source selection tag
I want to create new selection tag from souce selection tag.
workflow: select souce polygons and then x% polygons from souce selection deselect
when i use all polygons it works.
My problem is (except im novice) How to select only souce selection. how to get count of source seletion polygons.
Thank you
code here:
import c4d
import random
def main() :
obj = op[c4d.ID_USERDATA,4]#link gemometry
#obj = op.GetDown()
if obj == None:
return
selSourceTag = op[c4d.ID_USERDATA,4]#selection tag source
if selSourceTag == None:
return
selectionTag = obj.GetTag(5673)#selection tag final
if selectionTag == None:
selectionTag = c4d.BaseTag(c4d.Tpolygonselection)
obj.InsertTag(selectionTag)
selection = selectionTag.GetBaseSelect()
selSource = selSourceTag.GetBaseSelect()
if obj.GetType() != c4d.Opolygon:
return
selection.selSource #######################how to select only souce selection
for i in xrange(selSource.GetPolygonCount()) :
if random.random() <= 1-op[c4d.ID_USERDATA, 2]:
selection.Deselect(i)
op[c4d.ID_USERDATA, 1] = selectionTag
#update
op.Message(c4d.MSG_UPDATE)
c4d.EventAdd()