depending on Material-Name set a Layer

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

On 07/05/2009 at 11:40, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   11 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi all,
I have a new Problem ;.}
I want to set a layer to an objekt depending on the Material-Name of the objekt:
In words like this:
run through all ojekts
If "Material-Name" = xxx
    then
      set  Layer to the object = "YYY"
ende 
An other problem for me is to set the material-projekttion.
In words like this:
run through all ojekts
If "Material-Name" = xxx
   then
     set material-projektion = cubic
ende
Thanks so much for all your help.

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

On 11/05/2009 at 07:36, xxxxxxxx wrote:

Please be a bit more specific. What exactly is the problem?

cheers,
Matthias

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

On 12/05/2009 at 06:00, xxxxxxxx wrote:

Hi Mathias,
thanks for your replay.
Problem is, that we diddn't  know the structure of the databases in C4D.
So the programmming is to much try and error.
If there would be a stucture-diagramm it would be verry helpful.
The problem in the upper question is, that we want to set an existing layer to an existing objekt in case of it´s material-name.
So first we have go to the first objekt,
then read out the materal name,
then, set a Layer to the objekt.
For example:
Material = "Wood 01" asign object to Layer "01"
Material = "Metall 01" asign object to layer "02"
.
.
.

The problem we have is, that we do not know how to read out the material-name from the current object.
i seams verry simple, but we don't get the current material Name ;-}}}
cheers,
Ronny

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

On 13/05/2009 at 00:53, xxxxxxxx wrote:

Hallo Mathias,
hier unser aktueller Stand. Die rote Stelle macht mir probleme wiel ich nicht auf das Materialtag und den Namen des Materials komme.
#include "c4d.h"
#include "c4d_symbols.h"
 
class HelloWorld : public CommandData
{
public:
virtual Bool Execute(BaseDocument* doc);
};
/**
* This function is called by Cinema4D when the plugin shall be executed.
*/
void StepThruHierarchy(BaseObject *obj, LayerObject *layer)
{
while (obj && layer)
// hier kommt die Abfrage nach dem Materialnamen
//ich benötige den Namen des Materials
// mname = doc - >get...
__ 
{
obj->SetLayerObject(layer);
obj->Message(MSG_UPDATE);
StepThruHierarchy(obj->GetDown(), layer);
obj = obj->GetNext();
}
}
Bool HelloWorld::Execute (BaseDocument* doc)
{
StopAllThreads();
GeListHead *layerlist = NULL;
layerlist = doc->GetLayerObjectRoot();
if (!layerlist) return FALSE;
StepThruHierarchy(doc->GetFirstObject(), (LayerObject* )layerlist->GetFirst());
EventAdd();
return TRUE;
}
// -----------------------------------------------------------------
Bool RegisterV4D_1(void)
{
HelloWorld *helloWorld = NULL;
// initialize global resource object
if (!resource.Init()) return FALSE;
// create new instance of HelloWorld class
helloWorld = gNew HelloWorld;
return (RegisterCommandPlugin(PLUGIN_ID, GeLoadString (IDS_PLUGIN_NAME),0,"Icon.tif", GeLoadString (IDS_PLUGIN_DESCR), helloWorld));
}

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

On 13/05/2009 at 03:30, xxxxxxxx wrote:

Since you want to get the material of each object you simply have to get the material tag for each object and going from there to get the material assigned to the material tag.

Here is a little example printing the name of the first material of each object.

> \> void StepThruHierarchy(BaseObject \*obj) \> { \>      while (obj) \>      { \>           TextureTag \*ttag = NULL; \>           ttag = static_cast<TextureTag\*>(obj->GetTag(Ttexture)); \>           if (ttag) \>           { \>                BaseMaterial \*mat = NULL; \>                mat = ttag->GetMaterial(); \>                if (mat) GePrint(mat->GetName()); \>           } \> \>           StepThruHierarchy(obj->GetDown()); \>           obj = obj->GetNext(); \>      } \> } \>

cheers,
Matthias

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

On 13/05/2009 at 05:49, xxxxxxxx wrote:

Dear Mathias,
thanks for the help.
Now it becomes clearer how to jump from the objekt to a Tag!!
Tkanks so much
(next is following;-}}})