Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Login

    Nodes and attributes of GvOperatorData plugin

    Cinema 4D SDK
    c++ r23 s24
    2
    3
    354
    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.
    • fwilleke80F
      fwilleke80
      last edited by fwilleke80

      Hello,

      I'm writing an XPresso node, deriving its class from GvOperatorData.

      The node's .res file looks a bit like this:

      CONTAINER mynode
      {
      	NAME mynode;
      	INCLUDE GVbase;
      
      	GROUP ID_GVPROPERTIES
      	{
      		REAL MYNODE_ATTRIBUTE_1 { };
      		BOOL MYNODE_ATTRIBUTE_2 {  }
      	}
      
      	GROUP ID_GVPORTS
      	{
      		REAL INPORT_X { INPORT; NEEDCONNECTION; STATICPORT; CREATEPORT; }
      		REAL INPORT_SOMEVALUE { INPORT; EDITPORT; UNIT PERCENT; MIN 0.0; STEP 0.1; }
      		REAL OUTPORT_VALUE { OUTPORT; STATICPORT; CREATEPORT; }
      	}
      }
      

      In the code, in Bool MyNode::Calculate(), I do the following to get the values:

      	if (!GvCalculateInValuesTable(bn, run, calc, _ports))
      		return false;
      
      	BaseContainer* dataPtr = bn->GetOpContainerInstance();
      	if (!dataPtr)
      		return false;
      
      	if (port && port->GetMainID() == OUTPORT_VALUE)
      	{
      		// Get a value from a port
      		GvPort* const portInputValue = _ports.in_values[0]->GetPort();
      		Float inputValue = 0.0;
      		if (portInputValue)
      		{
      			if (!portInputValue->GetFloat(&inputValue, run))
      				return false;
      		}
      
      		const Float someFloatValue = dataPtr->GetFloat(MYNODE_ATTRIBUTE_2);
      		const Bool someBoolValue = dataPtr->GetBool(MYNODE_ATTRIBUTE_2);
      	}
      

      Getting the values works fine: When getting the value of a port, I'll get either the value that comes on from a connection in the node network, or I'll get the value from the Attribute Manager, if the port is not connected.

      Question
      However, the entry does not disappear from the Attribute Manager once I connect the port. In the builtin XPresso nodes, ports' attribute entry will vanish from the AM when the port is connected. How can I achieve that?

      By the way, full code is here:
      https://github.com/fwilleke80/Oscillator/blob/master/source/node/gvoscillator.cpp

      Thanks in advance & best greetings,
      Frank

      www.frankwilleke.de
      Only asking personal code questions here.

      ManuelM 1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel @fwilleke80
        last edited by

        hi @fwilleke80,
        thanks for providing the code, it helped to see where the problem was πŸ™‚
        You need to call the SUPER at the beginning (and not when returnning).
        And you don't need to load the description as you did with

        if (!description->LoadDescription(ID_OSCILLATORNODE))
        		return false;
        

        This code should work.

        	virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)
        	{
        	
        		if (!SUPER::GetDDescription(node, description, flags))
        			return false;
        		flags& DESCFLAGS_DESC::LOADED;
        		
        		
        		return true;
        	}
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • fwilleke80F
          fwilleke80
          last edited by

          Hi Manuel,

          oh right, that does the trick! Thank you, one bug less! πŸ™‚

          Cheers,
          Frank

          www.frankwilleke.de
          Only asking personal code questions here.

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