RDS Casa Posted December 4, 2017 Share Posted December 4, 2017 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 Quote Link to comment
RDS Casa Posted December 4, 2017 Author Share Posted December 4, 2017 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 Quote Link to comment
Marionette Maven Marissa Farrell Posted December 4, 2017 Marionette Maven Share Posted December 4, 2017 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. Quote Link to comment
RDS Casa Posted December 4, 2017 Author Share Posted December 4, 2017 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 Quote Link to comment
RDS Casa Posted December 4, 2017 Author Share Posted December 4, 2017 I've just found this discussion https://forum.vectorworks.net/index.php?/topic/42671-quotifquot-node-question/& I'm working my way through it, but none of the older files are attached so its difficult to follow. Does the valve node resolve all this? is there any guidance on this? Thanks again Quote Link to comment
RDS Casa Posted December 5, 2017 Author Share Posted December 5, 2017 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 Quote Link to comment
RDS Casa Posted December 5, 2017 Author Share Posted December 5, 2017 No, or at least I can't get it to work by adding it to the start of the extrude script. Quote Link to comment
Marionette Maven Marissa Farrell Posted December 5, 2017 Marionette Maven Share Posted December 5, 2017 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. Quote Link to comment
RDS Casa Posted December 5, 2017 Author Share Posted December 5, 2017 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? Quote Link to comment
Marionette Maven Marissa Farrell Posted December 5, 2017 Marionette Maven Share Posted December 5, 2017 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. Quote Link to comment
RDS Casa Posted December 5, 2017 Author Share Posted December 5, 2017 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. Quote Link to comment
RDS Casa Posted December 5, 2017 Author Share Posted December 5, 2017 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 Quote Link to comment
Marionette Maven Marissa Farrell Posted December 5, 2017 Marionette Maven Share Posted December 5, 2017 Correct, it would not work. The backend of VW in 2018 was updated to support this. Quote Link to comment
AlanW Posted December 7, 2017 Share Posted December 7, 2017 @RDS CasaHi, Here are my If network tests that may assist you. HTH Another_Way.vwx Circle_or_Square.vwx Drawsboth-01 (1).vwx Drawsboth-03.vwx If select items.vwx If_Node_Deleting_Objects (1).vwx If_Node_Deleting_Objects copy.vwx If_Node_Deleting_Objects.vwx if_statement (1).vwx number_of_doors.vwx Quote Link to comment
RDS Casa Posted December 8, 2017 Author Share Posted December 8, 2017 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. Quote Link to comment
RDS Casa Posted December 17, 2017 Author Share Posted December 17, 2017 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 Quote Link to comment
Marionette Maven Marissa Farrell Posted December 18, 2017 Marionette Maven Share Posted December 18, 2017 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? Quote Link to comment
RDS Casa Posted December 18, 2017 Author Share Posted December 18, 2017 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. Quote Link to comment
Marionette Maven Marissa Farrell Posted December 18, 2017 Marionette Maven Share Posted December 18, 2017 Hmmm. I'm not seeing this here. I'm not receiving an error. Could you attach a simple file? Quote Link to comment
RDS Casa Posted December 18, 2017 Author Share Posted December 18, 2017 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 Quote Link to comment
Marionette Maven Marissa Farrell Posted December 18, 2017 Marionette Maven Share Posted December 18, 2017 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. Quote Link to comment
RDS Casa Posted December 18, 2017 Author Share Posted December 18, 2017 Ah, awesome. Thanks Quote Link to comment
Recommended Posts
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.