Jump to content

Recommended Posts

HI

I know This is a kind of basic and lazy stupid question. the question is how do you find if there is same piece number has been shared by two or more pieces ?

For eg:- if you made 4 or 5 different fracture using the combination of voronoi and Boolean and you don't really know that if you named them correctly . but during the sim you noticed that some pieces are together. and you are lazy to go through all the pieces number in geo spreadsheet. what would be the easy and quick way to find two or more pieces are sharing the same piece number. ??   

Like a filter or something.   

i usually go to the view port and press 9 and toggle to name. then i move the mouse around the pieces. but then you dont really know if some pieces are shared with some really small piece.

Link to comment
Share on other sites

Got it! There's probably a more efficient way of doing this, but I'm currently learning python :)

First one, create a point attribute = 0 for all packed objects. Then plug in your packed geo in a python sop and copy this inside. Then if the point attribute repeat is equal to 1 you know that piece's name is doubled at least.

node = hou.pwd()
geo = node.geometry()

all_list = list()

for point in geo.points():
    repeat = point.attribValue("repeat")
    name = point.attribValue("name")
   
    if name not in all_list :
        all_list.append(name)

    elif name in all_list :
        repeat = 1
        point.setAttribValue("repeat", repeat)
        
for point in geo.points():
    if repeat == 1 :
        print name
   

I'd love to know how python experts would write this :)

Link to comment
Share on other sites

14 hours ago, beliveau.maxime said:

Got it! There's probably a more efficient way of doing this, but I'm currently learning python :)

First one, create a point attribute = 0 for all packed objects. Then plug in your packed geo in a python sop and copy this inside. Then if the point attribute repeat is equal to 1 you know that piece's name is doubled at least.

node = hou.pwd()
geo = node.geometry()

all_list = list()

for point in geo.points():
    repeat = point.attribValue("repeat")
    name = point.attribValue("name")
   
    if name not in all_list :
        all_list.append(name)

    elif name in all_list :
        repeat = 1
        point.setAttribValue("repeat", repeat)
        
for point in geo.points():
    if repeat == 1 :
        print name
   

I'd love to know how python experts would write this :)

Thanks for your effort Maxime. But i am really sorry. i never tried python scripting, so i dont know how to execute this above script.

Is there any other way to find/fix that problem?

Link to comment
Share on other sites

You can check for multiple of the same attribute value using the findattribvalcount() function in vex. I used this in a Attribute Wrangle set to Primatives

string val = prim(0, "name", @primnum);
int attrib_clash = findattribvalcount(0, "prim", "name", val);

if (attrib_clash > 1){
    setprimgroup(0, "clash", @primnum, 1, "set");
}

 

Link to comment
Share on other sites

13 hours ago, Parboil said:

You can check for multiple of the same attribute value using the findattribvalcount() function in vex. I used this in a Attribute Wrangle set to Primatives


string val = prim(0, "name", @primnum);
int attrib_clash = findattribvalcount(0, "prim", "name", val);

if (attrib_clash > 1){
    setprimgroup(0, "clash", @primnum, 1, "set");
}

 

yeah but...for a fragment that has say 10 faces/prims....they are all named piece123...so without even checking anything, you already know they have the same name...which is NOT a clash coz they're physically from the same piece...

Link to comment
Share on other sites

12 hours ago, Noobini said:

yeah but...for a fragment that has say 10 faces/prims....they are all named piece123...so without even checking anything, you already know they have the same name...which is NOT a clash coz they're physically from the same piece...

Awh think i misunderstood what was being asked. If you want to convert "Name" attribute into an integer and strip the "piece" you can try this. I've also made a new group per piece

i@p = atoi(strip(@name, "piece"));

string grp_name = sprintf("newGroup%d", @p);
setprimgroup(0, grp_name, @primnum, 1, "set");

@Cd = random(@p);

 

  • Like 1
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...