Jump to content
Developer Wiki and Function Reference Links ×

Dealing with conditional creation


Recommended Posts

I'm making a marionette object where the user can select if certain parts are present or not using the boolean checkbox. I cobbled together a conditional symbol node which allows a user to select whether or not a symbol is present in the final result.

The issue I'm having is some nodes downstream generate errors if no object is generated (e.g.. the user leaves the box unchecked). Nodes such as the duplicate node do not like empty input. Is there a way that I can end a branch of a network if no object is generated? For example, how do you recognize and deal with an empty list?

Someone was trying to do something similar in this thread - https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=218964#Post218964 - but it was a bit of a workaround.

Fundamentally there needs to be a way to achieve this. If you look at so many of VW's plugin object, they have the ability to turn on and off certain components (the column object for example allows for adding a base and capital). I would like to build that type of functionality into a marionette object.

Kevin

Link to comment

Kevin,

In the attached file I have adjusted one to give a warning if no symbol is present.

The original one was for if you chose less than 50 mm from bench front you got a warning.

Have a look and see if this assists you.

Email me a file if you want and I can have a look.

Also you could use the drop down list to choose to either have certain parts. Choose circle or rectangular.(See DP file attached)

Or also choose certain options.

See String of Lights for type of lights selection.

See light type choose 0,1,2 or 3,

HTH

Regards

Edited by Alan Woodwell
Link to comment

Hi Alan,

Thanks for the examples. I can tell you've spent a lot of time working with Marionette.

None of these are quite what I'm after. I want it to be ok for the user to choose the option of none and for the script to continue without an error. Using your sink in counter example, imagine if the user just wanted the counter (no sink). I want to use a boolean checkbox to turn options like the sink on and off. Part of the script will always generate something, its just the branch that generates nothing that is a problem and only when I ask it to act on potential geometry downstream. Essentially its an if/then where the then is do nothing.

There are various workaround that solve the issue, but they are workarounds not real solutions. They include adding loci so the result always contains something or grouping the result to something that always generates geometry so the null geometry doesn't matter.

There must be a way to trap a null (no geometry) result without all this messing around, otherwise how would you deal with dropdowns with a none option.

Kevin

Link to comment

Here's a simple example object. I've put a note in the script where I want to catch the null result. This script doesn't generate an error in its current form because the table is always generated so it doesn't matter if the vase is too.

It may be an edit to the code of the Conditional Symbol node I made. Perhaps it needs to branch somehow with an empty result.

Kevin

ubbthreads.php?ubb=download&Number=16051&filename=Screen%20Shot%202016-07-31%20at%209.15.12%20AM.png

Edited by Kevin McAllister
Link to comment

A little bit of thinking out loud here. I may be approaching this wrong. After revisiting the ideas from the Marionette Mondays, I wonder if I need to build a list first. Using Sarah's example of making cookies I'm trying to make cookies that contain optional ingredients like so -

flour

sugar

butter

optional-

chocolate chips

walnuts

raisins

In my case I'm actually making a set piece that is a pirate ship that is used in various configurations. My ingredients (symbols) are -

Ship Base

Ship Mid

optional parts to Ship Mid-

Ship Ladders

Ship Wheel

Ship Railing

Ship Stern - Open or Closed

The symbols have fixed offsets from a centre pivot. It seems to me the way to approach this is to develop a list of symbol names and their associated offsets first. Then this list (array?) can be used to insert symbols and generate geometry. The boolean checkboxes would be used to append things to the list. An example list would be -

Ship Base, 0, 0, 0

Ship Mid, 0, 0, 0

Ship Wheel, 0, -12, 96

Ship Railing, 0, -24, 96

Of course the number of things in the list would vary depending on what options the user turns on or off. I'm not sure how to error check the booleans that add nothing.

The ultimate goal of all this is to keep the amount of geometry in my file down and have an easy way to customize each instance of the ship. The pirate ship is fairly complex. Normally I would have made a composite symbol containing all of the parts separated by class, put a separate copy on its own layer for each position/scene and turn the classes on or off as needed in a sheet layer viewport. But this method means there are as many copies of the full pirate ship as there are scenes.

This all started because of this thread here - https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=230567#Post230567 - and the idea of a front end loader built in pieces.

Kevin

Link to comment

Thanks Alan. I didn't know about the Test List Node. Its not quite what I'm looking for but maybe I can cobble that into something useful. The user making a choice (Vase or No Vase in this case) isn't really an error. That's why I'm trying to trap the zero result so the user never gets an error.

They're really more like cut and paste skills rather than programming skills :-) What I'm missing is the algorithm logic skills that programmers are taught...

Kevin

Link to comment
  • Vectorworks, Inc Employee

Hi Kevin, I see in your Conditional Symbol node, if the boolean is false, you have a pass but instead you could set the output to equal None and then put add a list node to attach all objects to that filters out None values - as long as you have at least one object, the rotate node will work.

Link to comment

Hi Sarah,

This is where my lack of programming skills shows. To make my conditional symbol node I started with the 3d symbol node from the community board and added code from a boolean node, an if node and a dummy end node. Unfortunately I'm not sure how to set the output equal to none.

Ultimately what you're suggesting makes sense but is a different workaround to the same issue. What I really want to do is shown in the attached image. I want the bottom fork of the network to do nothing if the user chooses to leave off the optional object (eg. the boolean is false) rather than generating an error.

I put everything into the rotate node together in the original script because it worked around the error (same as in your case where you mentioned having at lease one object).

Can a node have two outputs, where one is used for one result and the other is used for a different result? This would only work if one output could be active at a time.

Thanks for your input.

Kevin

PS. I know it doesn't make sense to put the rotate node after the symbol node since I could just use the symbol rotation port. It just to illustrate that I want to act on the resulting geometry or do nothing if there's no geometry.

ubbthreads.php?ubb=download&Number=16063&filename=Screen%20Shot%202016-08-01%20at%209.37.32%20AM.png

Edited by Kevin McAllister
Link to comment
  • Marionette Maven

Hi Kevin,

Hopefully the file I'm attaching can help you out a bit.

It's easier to prevent the symbol from being included if you use an IF node right after the string with the name of the symbol you are considering.

Take a look and let me know if this helps at all.

There are many other ways to approach this, but I think this is (hopefully) inline with what you're hoping to accomplish.

Link to comment
  • Marionette Maven

I did a bit of cheating within the nodes... but this works..

The nodes I edited:

Symbol

Move

If you want me to explain what I did within those codes, I'm more than willing to elaborate.

(side note: In a 3D view you may still see some shifts on where the cylinder is placed. This is known and being worked on.)

Link to comment

Thanks Marissa.

What does the

if name != "":
line do that you added to the Symbol node ? And the
if i != vs.Handle(0):
line in the Move node?

I appreciate everyone taking the time to give suggestions. I think I'll leave it at that for now as my example was more a way of explaining my original question than a means to an end.

I'm looking for the equivalent to a switch in a room, which does something when someone turns it on, but does nothing otherwise. The light bulb doesn't generate an error message when it doesn't receive electricity.

Maybe someone could recommend a starters guide to forming algorithms, since it seems they are what Marionette is all about.

Thanks again,

Kevin

Link to comment
  • Marionette Maven

if name != "":

states "if name is not equal to [empty string]". In Python, != is "does not equal" and == is "equals"

This conditional tells the code to only run the script indented below that line to run if name is equal to something.

(I think doing "name != None" should have also worked, but I left it as is.)

if i != vs.Handle(0):

vs.Handle(0) is essentially an empty handle in Vectorworks, or a null handle. I tried using "None" instead of "vs.Handle(0)", but the error was still being returned, and this ended up working instead. It's not what I REALLY wanted to do there.

I think overall what Marionette needs is an update on its internal conditionals. Sarah and I have been working together to locate the nodes that could be improved with additional statements, and it's slowly coming along, but with such a vast library things either haven't been gotten to or have been overlooked.

I'd like to thank you (and everyone else) for asking questions, as that is the best way for us to see how we can help users to understand and utilize Marionette. I can understand without the plethora of documentation that Marionette deserves, it can really be a hit-or-miss on getting networks to behave as expected. We're definitely trying to tackle the issue of documentation internally, and I'm even working independently on my own time to create resources for you all.

I'll keep thinking on if there's any sort of guide that may help you in the meantime, though nothing has come immediately to mind.

Thanks again, and don't hesitate to ask more in depth questions if you ever need guidance!

  • Like 1
Link to comment

Hi Marissa,

This is super helpful information!

I really appreciate your guidance and your work behind the scenes. Unfortunately designers often think differently than engineers or programmers.

In the future it would be great to see an example of using the boolean or a dropdown where one of the options was none. Look at the VW column tool as a hard coded example. I downloaded many examples from the forums and couldn't find one.

Cheers,

Kevin

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