Jump to content

group to attribute .. ( python code )


zarti

Recommended Posts

hi all ,

yesterday i was working with profiles of a window. i needed to Sweep and Skin them, while preserving the manually assigned group names to later apply materials .

at the beginning, the ForEach SOP wasn't giving me the results with For's Each Group option . Each Attribute Value has always been 'kind with me' . =)

after searching in forums i didn't found something or felt tired and .. i gave Python a try .

here there are those lines pasted :

# This code is called when instances of this SOP cook.
geo = hou.pwd().geometry()

# Add code to modify the contents of geo.

groups = geo.primGroups()
group_list = []

for group in groups :
    group_list.append( group.name() )

#print group_list

mat_attrib = geo.addAttrib( hou.attribType.Prim, "group", "")

for group_name in group_list:
    for primitive in geo.iterPrims():
        if geo.findPrimGroup( group_name ).contains( primitive ):
             primitive.setAttribValue( mat_attrib, group_name )

create a new operator type > python type > geometry operator and paste this in the Code tab.

the attribute name is 'hard coded' to "group", but you can easily create a string input parameter for it.

... and so , my manually named groups 'survived' passing through foreachs , sweeps and skins =)

hope this wd help someone else in other cases too ..

attached pics shows what i was doing ...

post-5487-130512419664_thumb.png

post-5487-130512423932_thumb.png

post-5487-130512424472_thumb.png

post-5487-130512425283_thumb.png

Link to comment
Share on other sites

That looks cool. Nice rendering by the wall.

thanks !

beside the glass , all other shaders are colored irradiance vops , mixed with lambert ( 10-15% ), just to slightly catch the shadows of a single point light and 'naturally' shade the models .

i'm doing few short animated illustrations .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...