Jump to content
Sign in to follow this  
nicks

Turn off objects when placed in a null

Recommended Posts

Hi there,

 

I'm wondering if it's possible to do the following: I have a set of instanced objects, and I'd like to set the enable state to OFF, when they are placed into a Null object... I am guessing that I need to set a condition (ie. "if Object X is a child of Null Y, then set the enabled state to off" type of set-up), but I'm having trouble working out the conditional node - am I looking in the right place?

 

If anyone could give me a pointer, I'd sure appreciate it.

 

Cheers,

Share this post


Link to post
Share on other sites

44 minutes ago, nicks said:

Hi there,

 

I'm wondering if it's possible to do the following: I have a set of instanced objects, and I'd like to set the enable state to OFF, when they are placed into a Null object... I am guessing that I need to set a condition (ie. "if Object X is a child of Null Y, then set the enabled state to off" type of set-up), but I'm having trouble working out the conditional node - am I looking in the right place?

 

If anyone could give me a pointer, I'd sure appreciate it.

 

Cheers,

 

This is just a pointer in the right direction, not a complete solution.

You can assign a Python tag to your instance and implement the checking there as follows:

import c4d

def main():
    # 'op' is an internal defined variable
    # which represents the current "object",
    # in our case the Python tag
    if (op):
        # get the object hosting the Python tag
        hostObj = op.GetObject()
        # check if hostObj has a parent
        # and if it is a null
        parent = hostObj.GetUp()
        if parent and parent.IsInstanceOf(c4d.Onull):
            # do whatever is needed
            print "parent is null"
        

 

Share this post


Link to post
Share on other sites
  • Topic Author
  • Thanks for that - I'll have a play and see if I can get anything to work - Python is pretty far out of my comfort zone, but I do enjoy a good challenge!

     

    Cheers,

     

    Nick

    Share this post


    Link to post
    Share on other sites

    Yeah, hiding the code helps them learn a lot.

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • 18 hours ago, kalugin said:

    Yeah, hiding the code helps them learn a lot.

    @fxtree Thanks for that. It works, but I have not idea how you've done it... Any clues as to how you've done it would be much appreciated.

     

    @kalugin Well, on the upside I did learn that you can hide code from prying eyes! :lol:

    Share this post


    Link to post
    Share on other sites

    there was no code involve, it was pure xpresso, here is how to achieve it

    HideChildren.png

    Share this post


    Link to post
    Share on other sites

    @fxtree - the object's visibility sticks when you take it out of the null. Just making the null traffic lights red would achieve the same thing, but 'hidden' would not stick when the object is removed from the null.

    Share this post


    Link to post
    Share on other sites
    2 hours ago, jed said:

    @fxtree - the objects visibility sticks when you take it out of the null. Just making the null traffic lights red would achieve the same thing, but 'hidden' would not stick when the object is removed from the null.

    Yeah that's why i added user data on the null to hide and unhide or maybe i didn't understand the idea

    note that this setup doesn't  only set visibility but can be used to set any attribute at all.

    i am not sure you can set the radius of a sphere because null traffic lights is red

    Share this post


    Link to post
    Share on other sites

    In the original post, @nicks refers to enable - which is different to visible.

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      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.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...