Jump to content
Developer Wiki and Function Reference Links Read more... ×
mattao

Selected by String criteria

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

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×