Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Register
    • Login

    How to enable object X-Ray option - C++

    Cinema 4D SDK
    c++ sdk
    5
    19
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • r_giganteR
      r_gigante
      last edited by

      Hi mfersaui, unfortunately Cinema has not been designed to set the X-Ray option directly inside a GVO.

      What I instead recommend is to implement a NodeData::Message and react to MSG_MENUPREPARE.

      Best, Riccardo

      mfersaouiM 1 Reply Last reply Reply Quote 0
      • mfersaouiM
        mfersaoui @r_gigante
        last edited by

        @r_gigante
        Hi Riccardo, Thank you I will try this.
        Best.

        1 Reply Last reply Reply Quote 0
        • mfersaouiM
          mfersaoui @mfersaoui
          last edited by mfersaoui

          @mfersaoui

          Hi Riccardo,

          I try to do this in NodeData::Message. that works on the parent op. But how can I apply the X-Ray option on child object of node. because I want to apply the X-Ray only on some of node child objects.

          Best regards.

          Bool MyObject::Message(GeListNode* node, Int32 type, void* data)
          {
          
          	switch (type)
          	{
          	case (MSG_MENUPREPARE):
          	{
          		BaseObject* const op = static_cast<BaseObject*>(node);
          		
          		// op.GetCache()->GetDown()
          
          		break;
          	}
          	}
          }
          
          1 Reply Last reply Reply Quote 0
          • r_giganteR
            r_gigante
            last edited by

            Hi @mfersaoui, assuming you need to access the object pinned under your generator (actually the children), you should use op->GetDown() not op->GetCache()->GetDown().

            Best, Riccardo

            mfersaouiM 1 Reply Last reply Reply Quote 0
            • mfersaouiM
              mfersaoui @r_gigante
              last edited by mfersaoui

              @r_gigante
              Hi Riccardo,

              I have already tested to use op->GetDown(), but this crashing Cinema 4D.
              See example below:

              Bool MyObject::Message(GeListNode* node, Int32 type, void* data)
              {
              	switch (type)
              	{
              		case (MSG_MENUPREPARE):
              		{
              			BaseObject* const op = static_cast<BaseObject*>(node);
              			GePrint(op->GetDown()->GetName());
              			break;
              		}
              	}
              }
              
              r_giganteR 1 Reply Last reply Reply Quote 0
              • r_giganteR
                r_gigante @mfersaoui
                last edited by

                @mfersaoui before calling any method belonging to a pointer it's highly recommended to check for the pointer validity, so i would rearrange it as

                BaseObject* const op = static_cast<BaseObject*>(node);
                if (op->GetDown())
                	GePrint(op->GetDown()->GetName());
                break;
                

                This might prevent Cinema from crashing.

                Cheers, R

                mfersaouiM 1 Reply Last reply Reply Quote 0
                • mfersaouiM
                  mfersaoui @r_gigante
                  last edited by

                  @r_gigante I try it but nothing happen, it not detect any child object.

                  ferdinandF 1 Reply Last reply Reply Quote 0
                  • ferdinandF
                    ferdinand @mfersaoui
                    last edited by

                    @mfersaoui

                    Hm, stupid question: Does you object have actually any children? The parameter node passed to Message() is the actual GeListNode sitting in your object manager, representing your plugin instance. If this node has no children, this code does not make any sense.

                    Cheers
                    zipit

                    MAXON SDK Specialist
                    developers.maxon.net

                    mfersaouiM 1 Reply Last reply Reply Quote 0
                    • mfersaouiM
                      mfersaoui @ferdinand
                      last edited by mfersaoui

                      @zipit
                      My object contain a lot of child object, it is similar to the SDK Greek Temple Generator Example.

                      1 Reply Last reply Reply Quote 0
                      • ferdinandF
                        ferdinand
                        last edited by ferdinand

                        Well,

                        everything you are showing here suggests ottherwise. It sounds like GeListNode::GetDown() returns the null pointer for your node (which would both explain the crashes and the non-execution of your print statement).

                        Just to clarify again: node is the representation of your plugin instance in the editor, not the the root node of the object graph you did return in your GVO. If you want to access objects in the ouput of your ObjectData plugin GetCache() was the correct approach. But you also have to check the cache for null pointers, since there is no guarantee that any caches have been build when Message() is being executed.

                        Cheers
                        zipit

                        MAXON SDK Specialist
                        developers.maxon.net

                        1 Reply Last reply Reply Quote 0
                        • r_giganteR
                          r_gigante
                          last edited by

                          Hi @mfersaoui, I thought you were referring to objects pinned under the generator and not children in the cache. In this case checking that the cache is valid before attempting to access any of its methods is mandatory.

                          Last but not least, I think we're running out of options here, cause even attempting to use SpecialEventAdd() / MessageData::CoreMessage() doesn't help too much and leads on some cases to unpredictable results.

                          Best, Riccardo

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post