Jump to content
Developer Wiki and Function Reference Links ×

Selected by String criteria


mattao

Recommended Posts

Hi 

 

I just built this node to be able to "marionette" the "Crit" of Obj by Crit

 

You have to put the "criteria" text in the String Node. It will be passed to the new node and command his action.

By so you could act on the "criteria" string using marionette text and string nodes.

 

It seems to work.

 

Hope it will be useful.

 

I am pretty sure DomC has published something like that but cannot get my hand on it. Hi DomC. I am a fan of your work.

 

 

 

167980707_ObjbyCritMat.thumb.png.c3c69e10c8b993dbf837df039b424c5c.png

 

#COMMAND;REFFILE;[VWLibDef]/Input\Objs by Crit Mat.py;
#Modified August 2018
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
    #Name
    this = Marionette.Node( 'Objs by Crit Mat' )
    this.SetDescription( 'Returns a list of objects meeting the input criteria' )
    
    #Input Ports
    stringIn = Marionette.PortIn('', 's')
    stringIn.SetDescription( "The input string" )
    
    #Output Ports
    obj = Marionette.PortOut('h')
    obj.SetDescription('The list of objects in the document that match the criteria')
    
#BEHAVIOR

def RunNode(self):
    #inputs
    stringIn = self.Params.stringIn.value
    
    #script
    out_list = []
    
    def Add_Handle(obj):
        out_list.append(obj)
            
    vs.ForEachObject(Add_Handle,stringIn)
    
    wordTofind = "SEL=TRUE"
    searchInlist = stringIn
    searchInlist = searchInlist.replace(" ", "")
    if  wordTofind.lower() in searchInlist.lower():
        new_list = []
        parents_list = []
        for e in out_list:
            p = vs.GetParent(e)
            if  vs.GetType(p) == 11 and p in out_list:
                parents_list.append(p)
                pass
            else:
                new_list.append(e)
    
        for g in parents_list:
            if g in new_list:
                new_list.remove(g)
        #outputs
        self.Params.obj.value = new_list
    else:
        #outputs
        self.Params.obj.value = out_list

Edited by mattao
  • Like 1
Link to comment

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

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