Notifications
Clear all
[Closed] Recursive functions to find property
Mar 08, 2014 1:25 am
How can I write a recursive function to find a specific property such as ‘bend’ and once I find the first instance of the property I return the value and stop searching. I’d be searching through a selection of nodes.
6 Replies
1 Reply
Like this
fn findProperty node prop:#bend =
(
local found = off, result
for p in getPropNames node while found where (found = (p == prop)) do result = (getProperty node prop)
result
)
2 Replies
We can utilisez node var
fn findProperty node prop:#bend =
(
local found = off
for p in getPropNames node while found where (found = (p == prop)) do node = (getProperty node prop)
node
)
Mar 08, 2014 1:25 am
Ok. You are right.
fn findProperty node prop:#bend =
(
local found = off
for p in getPropNames node while found where (found = (p == prop)) do number = (getProperty node p)
number
)
Or slover solution
fn findProperty node prop:#bend = for p in getPropNames node where p == prop do exit with (getProperty node p)
Mar 08, 2014 1:25 am
Denis what would you recommend?
I essentially need to find a specific property on a node and once I find that property I need to get its value.