Jump to content

Loop over prims and delete


CinnamonMetal

Recommended Posts

Wrangles run over points/primitives in parallel, so you don't need to do a foreach. An if statement should do the job, something like:

if(@Cd == {1,0,0}){
	removeprim(0, @primnum, 1);
}

 

Edited by Sean-R
Fixed bracket type on vector
Link to comment
Share on other sites

Quote

i@slider = ch("rmprimitives");
if(@Cd.x > 0){
removeprim(0,@slider,1);
}

When I adjust the @slider which is a ch() only one primitive is deleted ?

Have a read of the removeprim() help, you are currently manually selecting which prim to delete with that slider attribute. @primnum calls the current primitive that is being run through the code, it will then delete that primitive if it matches the if statement.

 

Link to comment
Share on other sites

5 minutes ago, Sean-R said:

Have a read of the removeprim() help, you are currently manually selecting which prim to delete with that slider attribute. @primnum calls the current primitive that is being run through the code, it will then delete that primitive if it matches the if statement.

 

@slider is a ch() function which is what I wanted.  ;) Although I want to select the purplish / pink primitives; it appears tough as the colors are not typical solid plain colors ?

Link to comment
Share on other sites

Then you want to compare the @Cd attribute with a vector, either with a hardcoded vector like in my original code or a channel like you set up with the slider attribute. So:

v@minCd = chv("minCd")

@Cd > @minCd

What are you setting your slider attribute to? If you set the rmprimitives channel to something like "1" it ill only delete primitive 1.

Link to comment
Share on other sites

The slider attribute goes from 0-1 and as you mentioned it only deletes one primitive ? 

v@slder = chv("rmprimitives");
if(@Cd > @slder){
removeprim(0,@slider,1);
}

I'm trying to figure a way in Python to which I can select primitives with a range of a hue then export those as an attribute then I can use a ch() or chv() to control how many of those primitives get deleted. 

Link to comment
Share on other sites

Ah, I'm not too savvy with Python so can't help you there. If you want to do it in vex you would probably want to do this in two nodes. The first one would be the same as you have there but instead of using the removeprim() you can either create a group or set and attribute. Something like this:

if(@Cd > chv("Color")){
    @group_deleteMe = 1;
    }
    ;

You would then do the deleting in a second node, either by using a Delete node set to "Delete By Range", or by another if statement in a wrangle:

if(@group_deleteMe && rand(@primnum) < chf("threshold")){
    removeprim(0, @primnum, 1);
}
;

Hopefully someone can help with the Python side of things!

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...