Notifications
Clear all

[Closed] Temp Parent

Hello All

Just playig arond with a litle script to that scans in the parent of a series of objects into an array then unparents them. When the artist has finished modifiying the none parented object he can then re-apply the same parent child relationship as before. Im a little stuck. Still fleshing this out. Eventualy these will be on buttons and no I am not trying to run this all at once

The problem I have , im sure is simple. When I go to re-parent the objects I get, the bottom section.
– No “map” function for 2

[color=white]Which I sort of understand as the parent command wants an object. But if I test run this line the command I use is returning what should work. Any help would be great.

Thanks

Harry

[/color]——————–
– This section creates the 2 arrays one for the parent and one for the child.
MyParents = for i in selection where i.parent != undefined collect

(

i.parent

)

MyObjects = for i in selection where i.parent != undefined collect

(

i

)

– This section unparents the objects
for i in selection where i != undefined do

(i.parent = undefined)

– This section puts the, back together.

for i in myparents.count do
(myobjects[i].parent = myparents[i])

2 Replies

for i in myparents.count do …

should be

for i = 1 to myparents.count do …

or

for i in 1 to myparents.count do …

As it is now, IN means that the FOR loop should loop through all elements of a collection (like in FOR i IN someArray DO… or FOR i IN SELECTION DO…). But myparents.count is equal to 2 which is not a collection or array, so the mapping operation (the attempt to iterate through elements of a collection or array) fails and you get the error that tells you so.

Hey Bobo

Thanks for getting back and clearing that up. I always get the loops mixed up when it comes to the count value

I will try this later.

Thanks

Harry