Hello Python and Stack community in general.
First, let me say I'm a 3d guy and not much of a code guy. So thanks for the understanding...
The exact problem: I have to generate a gradient map based on a distance from points to multiple objects
Here is a simple preview of what my problem looks like Preview_C4D
My base code is the following:
import c4d
#Welcome to the world of Python
warray = [0.0]
def main():
global warray
wtag = op[c4d.ID_USERDATA,1] #drag vertex map from user data panel
obj = wtag.GetObject() #the object of the vertex map
pts = obj.GetAllPoints()
cnt = len(pts)
null = op.GetObject()
nullpos = null.GetMg().off #vector magnitude from matrix
minDistance = op[c4d.ID_USERDATA,4] #drag slider map from user data panel
maxDistance = op[c4d.ID_USERDATA,5] #drag slider map from user data panel
if len(warray) != cnt:
diff = cnt - len(warray)
warray.extend([0.0]*diff)
for x in xrange(cnt): #remapping in the range 0-1
point = pts[x]
distance = (nullpos - point).GetLength()
warray[x] = c4d.utils.RangeMap(distance,minDistance,maxDistance,1,0,False)
if warray[x] > 1:
warray[x] = 1.0
elif warray[x] < 0:
warray[x] = 0.0
wtag.SetAllHighlevelData(warray) #bake the new vertex map
Now lets say I have a list with multiple objects:
parent = doc.SearchObject('parent')
list1 = parent.GetChildren() # list of cubes under parent
count = len(list1)
for a in range(list):
obj = list1[a]
distance = ?
So I'm stuck here, because I can't figure it out how to merge the new values with the old. In few words I need a loop that evaluates the values for the points for each object in the list and then adds them toghether. I just can't dial it up right.
So I'll be very grateful if anybody can help.
Regards