Search - User list
Full Version: Measuring objects (and retrieving the result in Python)
Root » Technical Discussion » Measuring objects (and retrieving the result in Python)
dagush
Hi all,

I have two questions that I hope are not too silly… -)

I have a collection of objects that want to measure their total area, and then I want to delete some subparts depending on the individual area vs. average/total area sizes. As I know I am not explaining myself clearly, in the attached file you can se how we load an image file of a city map, convert it to a set of polygons (blocks), and then delete some of them if a variable called AREA is smaller than a constant value

$AREA < 0.002

Now, I would like to change that into something like

$AREA < $TOTALAREA / nprims('../……')

but, firstly, I don't know how to measure the total area. I tried using another measure node at the end of the chain, but I'm clearly doing something wrong, as it din't work. Also, I foresee another serious problem which I can't figure out how to solve the measure node that computes the TOTAL area, and as Houdini is dynamically recomputes everything, as soon as the delete operator deletes a few nodes, the total area will change, growing. Thus, the global variable would be updated, and more nodes will be deleted, as they do not fullfill the criteria any longer, thus making the total remaining area even larger! As you can see, I'll end up having ony a few (if any) equally sized polygons! I would have erased the whole city!

As a final question, and I hope it has not been asked zillions of times before, how can I know the $TOTALAREA variable (or any measurable value) from within Python? I mean, as I create the nodes, if I want to write 564 instead of $TOTALAREA, how can I know which the value of $TOTALAREA is?

Thankyou very much for all your help!!

cheers

dagush.-
rdg
couldn't read the complete post as I was distracted by the image

to get the total area:
first: use measureSOP set to area like you already have.
second: attributePromoteSOP set to sum and promote area to a detail attribute

hope this helps
Pagefan
Is it the map of Venice?

Duh, says Girona on the image…
dagush
Hi all,

THANKS FOR THE ANSWER!!!

I've checked everything I've found about the atttribPromote node, and now I think I understand it quite well. The problem is that I am missing some details of how to use it. I've created an attribPromote node (attribpromote1) and I've decided that the “average” promotion method is exactly what I need, and I've associated a new variable called $AVGAREA. I've plugged the measure node into the attribPromote, and that one into the delete. Then, I changed the delete to use the expression

$AREA < 0.1 * details('../attribpromote1','AVGAREA')

and it doesn't give an error, but is not working either. It is as I read in a previous forum, but no details were given about the details function… I'm attaching the non-working example…

thanks in advance for your kindness!!!!

dagush.-
PS BTW, it is the city of Girona, Spain… -)
dagush
Hi all,

Just to mention it, I've just changed the node language in the “delete” node to Python, and wrote

hou.node('/obj/geo1').geometry().attribValue('AREA') < 0.2 * hou.node('/obj/geo1').geometry().attribValue('AVGAREA')

but I'm still doing something wrong, right? What?

thanks a lot!!!

dagush.-
edward
Changing the language icon only changes the default language that is used when creating expressions I think. So you probably need to specifically right-click on your parameter and switch it to the right language.
dagush
Hi,

I've tryied changing the language to python, but it seems it is not the problem. I've also changed several combinations of the nodes to get the attributes from, but it seems I haven't understood how it works, as it is not working. It seems easy to get right, but I cannot figure out how…
Just in case, I'm attaching the file with the Python code I wrote as parameter for the delete operator…

Thanks again for all your help…

dagush.-
midorime
Hi dagush,

Did you solve your problem…. ?

I don't know about Python in Houdini yet, I'm new on Houdini,
so I tried to fix your scene, as rdg said, without using Python…

…and it works… the delete sop deletes every primitive smaller than the average value without modify the amount of total area, so we don't have a recursive process…

…maybe I haven't understood your problem… ops:
dagush
GREAT!!!!!

Thank you a lot!!!!

It IS exactly what I needed!!!! Thank you very much!!!!

dagush.-
PS Now I can figure the python code out by myself… I just couldn't get the attribPromote right!!!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB