Jump to content
Developer Wiki and Function Reference Links ×

If node, boolean and popups


RDS Casa

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

Link to comment

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

Link to comment

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

 

 

 

Link to comment
  • Marionette Maven
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.

Link to comment

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?

Link to comment
  • Marionette Maven

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.

Link to comment

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. 

Link to comment
  • 2 weeks later...

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

 

Link to comment

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.

 

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