A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
If/Then with Objects in XPresso
Posted: 20 November 2020 10:28 PM   [ Ignore ]  
Avatar
Total Posts:  80
Joined  2012-05-01

Hello,

I have an Integer attribute in my User Data. If the Integer is, say, 1, I would like to pass one object to an Instance object. If it’s 2, I’d like to pass another. Is this possible?

My first attempt was using Link List, but one of my objects is coming from a Link attribute in the User Data, so it will be unknown. I’ve attached a scene file to demonstrate my setup.
https://drive.google.com/file/d/1VOMQLh20IyCU6Xnb-0dPBaIWXYXNsR2T/view?usp=sharing

Thank you!

Profile
 
 
Posted: 20 November 2020 10:56 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi blastframe,

Thanks for using Google, and the file.

The values can be used in a Condition node directly (set to Object).

I have placed a second version into the file as well; please have look:
https://www.amazon.com/clouddrive/share/2PaCuNdAeDryjmUmSa3QrcqTVcBbRByxWF8aRQ88TWa

Besides, if you want to have an if/then logic in Xpresso, use the Formula Node, please.

?($1=4;1;0)

Which reads, if input one equals 4, then provide 1 as output, otherwise 0. All numbers can be used here, not limited to 1 or 0, and each result could be another if/then statement.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 20 November 2020 10:59 PM   [ Ignore ]   [ # 2 ]  
Avatar
Total Posts:  80
Joined  2012-05-01

Hello, I’m sorry for the trouble. I think I’ve got it: I have created two new XPresso tags: one has the Link output connected to the Instance Object’s Reference Object Input and the other has the other object connected to the Instance Object’s Reference Object Input. The “Master” XPresso tag enables one or the other XPresso tags based on the Integer.

Profile
 
 
Posted: 20 November 2020 11:00 PM   [ Ignore ]   [ # 3 ]  
Avatar
Total Posts:  80
Joined  2012-05-01

Hahahaha, you are so fast! I will check out your setup, which looks better if it’s only one tag.

Profile
 
 
Posted: 20 November 2020 11:02 PM   [ Ignore ]   [ # 4 ]  
Avatar
Total Posts:  80
Joined  2012-05-01

Okay, your solution is much more elegant and efficient. I didn’t know the Condition node can pass objects. Thank you so much, Dr. Sassi!

Profile
 
 
Posted: 20 November 2020 11:03 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Blastframe, let me know if there is anything else you need, and I’m happy to look into it.

Keep your solution in mind, as sometimes that can help to declutter a setup.

Thanks for the kind feedback.

Have a great weekend

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile