Determining state of an object

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 12:28, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Platform:      
Language(s) :

---------
I was wondering if it is possible to determine if an object has been made editable. Can someone push me toward and example or function that does something like this.

Thanks,

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 14:28, xxxxxxxx wrote:

Not really. If you knew it was procedural beforehand, you could check its type somehow using op->IsInstanceOf(Opolygon) but I wouldn't depend on this. The question is knowing when it was made editable. A core message may be broadcast or if your plugin is a tag on the object you want to check you should get some sort of messages when this happens. Otherwise, you are going to need a SceneHook plugin to track the document.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 17:00, xxxxxxxx wrote:

okay .. so I am setting this up in the GetDEnabling ()member which includes which looks like this...

> `

  
\>  Bool TrueSymmetry::GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)  
\>  {       
\>       /////////////////CHECK FOR EDITABLE///////////////////////  
\>       PolygonObject* op;  
\>       BaseContainer &data; = *((BaseObject* )node)->GetDataInstance();       
\>       BaseContainer* bc;  
\>    
\>       PolygonObject* objPoly;  
\>       objPoly=(PolygonObject* )op;  
\>       if (!objPoly->IsInstanceOf(Opolygon))  
\>       {  
\>    
\>            GePrint ("The object is NOT Editable");  
\>                 switch (id[0].id)  
\>       {     case SYMMETRY_PLANE:            
\>                 return !blnSymmetryActive;  
\>       }  
\>                 return FALSE;  
\>       }  
\>       else  
\>       {  
\>            GePrint ("The object is editiable");  
\>                 switch (id[0].id)  
\>       {     case SYMMETRY_PLANE:            
\>                 return !blnSymmetryActive;  
\>       }  
\>                 return TRUE;  
\>         
\>       }  
\>       ///////////////////////////////////////////////////////////  
\>    
\>       // Enable/disable our parameters  
\>    
\>       switch (id[0].id)  
\>       {     case SYMMETRY_PLANE:            
\>                 return !blnSymmetryActive;  
\>       }  
\>       return TRUE;  
\>  }  
\>    
\>  

`

I get the following errors.

(129) : warning C4700: uninitialized local variable 'op' used
(126) : warning C4101: 'bc' : unreferenced local variable

I know that these warnings are because neither of these variables are initialized in the GetDEnabling () member.

How do I initialize them within the member function without having to add BaseObject* op, and BaseContainer*, bc to the arguments. As this causes the GetDEnabling() to not execute properly.

Thanks,

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 17:11, xxxxxxxx wrote:

Not sure what you are trying to achieve here. This code is a bit cleaner but you return the same value (!blnSymmetryActive) whether it is a polygon object or not:

> Bool TrueSymmetry::GetDEnabling(GeListNode \*node, const DescID &id;,GeData &t;\_data,LONG flags,const BaseContainer \*itemdesc) \> {      \>      /////////////////CHECK FOR EDITABLE/////////////////////// \> // Is the plugin a tag plugin? \>      BaseObject\* op = (BaseTag\* )(node)->GetObject(); \>      // ??? Not used - BaseContainer\* bc =     (BaseObject\* )(node)->GetDataInstance(); \>       \>      if (op->IsInstanceOf(Opolygon)) \>      {      \>           GePrint ("The object is NOT Editable"); \>           switch (id[0].id) \>           { \>                case SYMMETRY_PLANE: \>                     return !blnSymmetryActive; \>           } \>           return FALSE; \>      } \>      else \>      { \>           GePrint ("The object is editiable"); \>           switch (id[0].id) \>           { \>                case SYMMETRY_PLANE: \>                     return !blnSymmetryActive; \>           } \>           return TRUE; \>      } \>      /////////////////////////////////////////////////////////// \>       \>      // Enable/disable our parameters \>      switch (id[0].id) \>      { \>           case SYMMETRY_PLANE: \>                return !blnSymmetryActive; \>      } \>      return TRUE; \> }

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 17:16, xxxxxxxx wrote:

I am trying to set it up so that if it is an editable polygon, then the checkbox is enabled,

if it is not an editable polygon, the checkbox is not enabled.

What should I change to make it do that.

Also, when I use this code, It makes Cinema 4D crash and tells me that
"op" is not being initialized.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 17:22, xxxxxxxx wrote:

There is really no such thing as an editable polygon object. There is, but you won't be able to tell (has deformers under it for instance). The only determinable thing that is editable is something that isn't a polygon object (Ocube, Onull, Osds, etc.).

Get the BaseContainer, as I showed but uncommented, and set the value accordingly:

bc->SetBool(SYMMETRY_PLANE, TRUE);
- or -
bc->SetBool(SYMMETRY_PLANE, FALSE);

I wouldn't do this in GetDEnabling() as it is strictly for enabling/disabling (greying out of) of the plugin's Attribute Manager elements. Execute() may be more appropriate but GetDDescription() if you are overriding that function.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 17:39, xxxxxxxx wrote:

That's what I want it to do.. I want it to gray it out if it is not a polygon object

So I think I need to do it in GetDEnabled..

Is there a way to initialize op within GetDEnabled?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:12, xxxxxxxx wrote:

Ah. Then you must return TRUE (enable) or FALSE (disable) from GetDEnabling(). This is on a case by case basis (by description ID).

> Bool TrueSymmetry::GetDEnabling(GeListNode \*node, const DescID &id;,GeData &t;\_data,LONG flags,const BaseContainer \*itemdesc) \> {      \>      /////////////////CHECK FOR EDITABLE/////////////////////// \>      BaseObject\* op = (BaseTag\* )(node)->GetObject(); \>       \>      switch (id[0].id) \>      { \>           case SYMMETRY_PLANE: \>                if (op->IsInstanceOf(Opolygon)) \>                {      \>                     GePrint ("The object is NOT Editable"); \>                     return FALSE; \>                } \>                else \>                { \>                     GePrint ("The object is editiable"); \>                     return TRUE; \>                } \>      } \>      return TRUE; \> }

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:21, xxxxxxxx wrote:

Thank you for your help..

Now I get this error.

> `

  
\>  1>c:\users	he fosters\desktop\cinema4dr11010\plugins	ruesymmetry\source	ag	ruesymmetry.cpp(124) : error C2039: 'GetObject' : is not a member of 'GeListNode'  
\>  1>        c:\users	he fosters\desktop\cinema4dr11010\resource_api\c4d_baselist.h(380) : see declaration of 'GeListNode'  
\>  

`

:)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:35, xxxxxxxx wrote:

I think you can do it one of these two ways (this always confuses me when going into the casted class) :

(BaseTag* )node->GetDataInstance();

or

static_cast<BaseTag*>(node)->GetDataInstance();

The first is C style and the second is C++ style. I've been trying to do the C++ style as it is more clearly determined in the C++ standard than the old C style.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:49, xxxxxxxx wrote:

LOL.. well At least I got a different error this time.

1>c:\users he fosters\desktop\cinema4dr11010\plugins ruesymmetry\source ag ruesymmetry.cpp(126) : error C2440: 'initializing' : cannot convert from 'BaseContainer *' to 'BaseObject *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

I tried both C and C++ style C style gave me the original error. C++ style gave me the above error.

:)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:50, xxxxxxxx wrote:

current code

> `

  
\>  Bool TrueSymmetry::GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)  
\>  {       
\>       /////////////////CHECK FOR EDITABLE///////////////////////  
\>    
\>         
\>        BaseObject* op = static_cast<BaseTag*>(node)->GetDataInstance();  
\>       switch (id[0].id)  
\>       {  
\>            case SYMMETRY_PLANE:  
\>                 if (op->IsInstanceOf(Opolygon))  
\>                 {       
\>                      GePrint ("The object is NOT Editable");  
\>                      return FALSE;  
\>                 }  
\>                 else  
\>                 {  
\>                      GePrint ("The object is editiable");  
\>                      return TRUE;  
\>                 }  
\>       }  
\>       return TRUE;  
\>         
\>       // Enable/disable our parameters  
\>       switch (id[0].id)  
\>       {  
\>            case SYMMETRY_PLANE:  
\>                 return !blnSymmetryActive;  
\>       }  
\>       return TRUE;  
\>  }  
\>    
\>              
\>  

`

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 18:58, xxxxxxxx wrote:

Obviously,

BaseObject* op = static_cast<BaseTag*>(node)->GetDataInstance();

is not correct. You want the object of the tag not the BaseContainer, so use:

BaseObject* op = static_cast<BaseTag*>(node)->GetObject();

Also, the second switch() will never be encountered. If you want to do both setting by the type of object and allow it to be set using blnSymmetryActive, you will need to combine the two sets of conditions (&& or ||) under the first switch() statement.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 19:03, xxxxxxxx wrote:

Bool TrueSymmetry::GetDEnabling(GeListNode \*node, const DescID &id;,GeData &t;\_data,LONG flags,const BaseContainer \*itemdesc) \> {      \>      /////////////////CHECK FOR EDITABLE/////////////////////// \> \>      switch (id[0].id) \>      { \>           case SYMMETRY_PLANE: \>                   BaseObject\* op = static_cast<BaseTag\*>(node)->GetObject(); \>                if (op->IsInstanceOf(Opolygon)) \>                {      \>                     GePrint ("The object is NOT Editable"); \>                     // blnSymmetryActive won't change this outcome ;) \>                     return FALSE; \>                } \>                else \>                { \>                     GePrint ("The object is editiable"); \>                     return !blnSymmetryActive; \>                } \>      } \>      return TRUE; \> }

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/08/2009 at 19:14, xxxxxxxx wrote:

lol..   works like a champ now..

Thanks for your help Robert. You are a true help and a wonderful resource.

Thanks,

~Shawn