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

If node, boolean and popups

Recommended Posts

Hello all.

 

I've been going through the forum examples looking for examples of the If node. I can't find any (please direct me if there are any) , so I've been left to experiment.

 

I can get it to work with a Boolean input, i.e. a tick box in the OIP

 

But how do I get it to work from a pop up menu? What I'm trying to do is use a pop up to drive the geometry in a marionette object. Say a chair,  with the popup menu to change the cushion from round, to square, to triangular? 

 

I can create the popup, and have it assign values to the chosen option, but a bit stuck where to go from here.

 

Any examples of similar actions?

 

Is there a simple node to convert a value, 0 or 1 into a true / false boolean? I think that would do it.

 

maybe the if node is not the best way?, but I imagined some kind of

if round do this,

if not round then if square do this

in not round, if not square, then do this.

 

Some logic chain like this for the number of options... something like this at any rate.

 

Thanks

Share this post


Link to post

Actually the Boolean strategy does not work, I get an "invalid callback function parameter type" error, because the extrude node has nothing to extrude. I'm expecting it to have nothing to extrude, when the boolean is false. 

 

(it works for not creating a rectangle, with a 0 width for example, but falls over when it tries to push the non existent rectangle on to a extrude node.

 

I can't find a stop node.

 

I can't work out how the delete node would work if I created all the geometry then deleted the bits I don't need?

 

Any ideas??

 

Thanks

Share this post


Link to post

Which version are you using? In 2018, a valve node was introduced that could help with this.

Otherwise, I can try to mock up an example in the next day or so, once work dies down a little bit.

Share this post


Link to post

Thanks. I'm trying to sort my vss for 2018, might have it sorted by end of week, but I'd still like to understand the example in 2017 because there are a few other scenarios in similar problems I need to resolve. So if you can, it might really help. Thanks so much  

Share this post


Link to post

Hello again,

 

I've been playing with the delete node at the end of an if node should the test prove false. Its fine when the tick box (include additional geometry) is not ticked as the geometry is deleted. But there is an error message when the button is ticked (i.e. the additional geometry is to be included), because the delete node has nothing to delete.

 

What I have discovered is that the modified delete node at the end of this discussion does not return error message

 

https://forum.vectorworks.net/index.php?/topic/42671-quotifquot-node-question/&

(the only file still on there to down load?, at the very end)

 

Thats fine, but I like to understand why these things work and I don't?

 

The only difference in the code:

def RunNode(self): #this is as per library node

    if self.Params.obj.value != vs.Handle(0): #this is the additional code

        vs.Marionette_DisposeObj(self.Params.obj.value) #this is as per library node

 

Clearly I'm not a python coder: is this single line saying only run the delete (disposeObj action) IF there is a object being operated on (a handle)

 

And if so, should this work for any other nodes which are falling over due to a lack of things to process?? Because then I might fit it in to the extrude node when there are no objects to extrude?

 

I'm guessing, any advice gratefully received. 

 

Thanks

 

 

 

Share this post


Link to post
3 hours ago, RDS Casa said:

The only difference in the code:

def RunNode(self): #this is as per library node

    if self.Params.obj.value != vs.Handle(0): #this is the additional code

        vs.Marionette_DisposeObj(self.Params.obj.value) #this is as per library node

 

 

This states

"If the object passed is not an empty handle (is a handle), then delete this object."

This prevents the node from trying to delete information it can't, and prevents the script from running if the value is not of the correct type.

Share this post


Link to post

Thanks. So I hoped this might work in other scripts, but it does not (at least for me) . For example, I need to group all the objects at the end, but if the object is deleted, the group node returns an error., or if a parameter is zero, a rectangle is not formed (ok) but then the extrude node falls over (not ok)

I'm hoping this valve node resolves all these. Does it work like a stop? And why is there no if/else node?

Share this post


Link to post

could you post the file containing your script, or send it privately? I can try to work out a better way to do it for you.

The valve node would most likely solve this problem, though. It's fed a boolean true/false and if it receives false, the rest of the nodes after that point will not run.

 

The if node is basically an if else.

Share this post


Link to post

Actually, that exactly what I need. I'd love you to go through my script and engineer out the bugs, but I should get VW2018 in a matter of days, and by the sound of it the valve will stream line the process quite a bit, so that's probably going to save us both quite a bit of time. 

A kind offer though, thank you. 

Share this post


Link to post

Actually I do have a very quick question: If I had a marionette object, with a valve node from 2018, and I tried to put that object into 2017 for others, I'm guessing it simply would not work?

Thanks  

Share this post


Link to post

Thanks so much, I'll go through these next week. Your previous post have been absolutely instrumental in helping me progress through marionette, so I'm rather excited about going through these!

Thanks again for all your posts, they have been fantastic.

Share this post


Link to post

Thanks @Alan Woodwell

So the Max item on a double if can work like a If this OR that true, then true, if both true then true, if both false then false ? neat trick.

 

@Marissa Farrell

I tried using your    

if self.Params.obj.value != vs.Handle(0):

extra in the attributes node, to stop the node falling over if something is not there.

 

On 05/12/2017 at 1:50 PM, Marissa Farrell said:

 

This states

"If the object passed is not an empty handle (is a handle), then delete this object."

This prevents the node from trying to delete information it can't, and prevents the script from running if the value is not of the correct type.

 

Can it work in this capacity at the top?  Where am I going wrong? I added the python 4 space indentation to everything below it? 

 

 

 


def RunNode(self):
    if self.Params.obj.value != vs.Handle(0):
        if self.Params.IN.value != 0:
            h =  self.Params.IN.value
        
            if vs.IsFillColorByClass(self.Handle):
                vs.SetFillColorByClass(h)            
            else:
                vs.SetFillBack(h, vs.GetFillBack(self.Handle))
                vs.SetFillFore(h, vs.GetFillFore(self.Handle))

            if vs.IsFPatByClass(self.Handle):
                vs.SetFPatByClass(h)
            else:
                vs.SetFPat(h, vs.GetFPat(self.Handle))

            if vs.IsLSByClass(self.Handle):
                vs.SetLSByClass(h)
            else:
                vs.SetLSN(h, vs.GetLSN(self.Handle))

            if vs.IsLWByClass(self.Handle):
                vs.SetLWByClass(h)
            else:
                vs.SetLW(h, vs.GetLW(self.Handle))
        
            if vs.IsMarkerByClass(self.Handle):
                vs.SetMarkerByClass(h)
            else:
                ok, style, angle, size, width, thickBasis, thickness, visibility = vs.GetObjBeginningMarker(self.Handle)
                vs.SetObjBeginningMarker(h, style, angle, size, width, thickBasis, thickness, visibility)
                ok, style, angle, size, width, thickBasis, thickness, visibility = vs.GetObjEndMarker(self.Handle)
                vs.SetObjEndMarker(h, style, angle, size, width, thickBasis, thickness, visibility)

            if vs.IsPenColorByClass(self.Handle):
                vs.SetPenColorByClass(h)
            else:
                vs.SetPenFore(h, vs.GetPenFore(self.Handle))
                vs.SetPenBack(h, vs.GetPenBack(self.Handle))

            if vs.IsTextStyleByClass(self.Handle):
                vs.SetTextStyleByClass(h)        

            xOrigin, yOrigin, xIAxis, yIAxis, xJAxis, yJAxis = vs.GetFillPoints(self.Handle)        
            vs.SetFillIAxisEndPoint(h, xIAxis, yIAxis)        
            vs.SetFillJAxisEndPoint(h, xJAxis, yJAxis)
            vs.SetFillOriginPoint(h, xOrigin, yOrigin)

            if vs.GetOpacityByClass(self.Handle):
                vs.SetOpacityByClass(h)
            else:
                vs.SetOpacity(h, vs.GetOpacity(self.Handle))
            

        self.Params.OUT.value = self.Params.IN.value

 

Share this post


Link to post

I'm not sure I understand what you're trying to do here.

This node already checks to see if a handle was passed to it.

 

Could you explain better what you're trying to accomplish?

Share this post


Link to post

I have some networks in 2017, so without the valve node. They are working, but all I need to do is set the attributes of the objects. But when I use the attributes node, and the shape never gets made, it gives an error command. I assumed this was because there was no object to apply the attributes to?

 

This can be recreated quickly with a simple rectangle node. Attach inputs to width and height, then put the attributes node at the end. All fine if the inputs are 2 and 3. But if an input becomes 0, and the rectangle does not get made, it returns an error and identifies the Attributes node. 

 

Thanks for your help as always.

 

Share this post


Link to post

Strange. Try this.

 

Is it a 2017 thing? many jobs here are on site and are in 2017, and we really don't want to convert if we don't have to. I know they say its fine, but sometimes it isn't (been there before). New projects are starting or converting to 2018, but not the ones on site

 

Thanks. 

simple attributes problem.vwx

attributes capture.JPG

Share this post


Link to post

Ah yep. There it is in 2017, but not 2018.

 

if you change

 

	if self.Params.IN.value != 0:

to 

	if self.Params.IN.value != vs.Handle(0):

it should eliminate that error.

 

Edit:

I'll make a note in bug tracking to get this updated.

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.

×