Material Marker for dumi
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2003 at 05:46, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.012
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;---------
Hello,
I am very stupid but I can't find why It is not working:
Id'like to set a material to a cube, here is my code:
main(doc,op)
{
var MonMark = new(Marker);
var matiere=doc -> FindMaterial("BlackScreen") ;
if (!matiere) //Make mymaterial
{
matiere = new(Material) ;
matiere -> SetName ("BlackScreen");
MonMark=matiere->GetMarker();// I get the Marker here!!!!
doc ->InsertMaterial (matiere,NULL) ;
matiere -> Update () ;
}
var MonGroup=op->GetDown() ;
if (!MonGroup)
{
MonGroup=new(PrimitiveObject) ;
MonGroup->SetName("My Object");
MonGroup->SetPrimitiveType(PRIMITIVE_CUBE);
var MonTag = new(TextureTag);
// MonTag->SetMaterial(MonMark);// Here I try to set mymaterial to the TextureTag of "my object"MonGroup->InsertTag(MonTag,NULL);
doc->InsertObject(MonGroup,op,NULL);
}
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2003 at 11:48, xxxxxxxx wrote:
Hello Platane !
I just sent you the working code by mail, but I put it there for everybody:
// This function update the C4D document
Refresh(mydoc)
{
mydoc->Message(DOCUMENT_CHANGED);
GeEventAdd(ACTIVE_OBJECT_CHANGED);
}
// Main function
main(doc,op)
{
// 1 - We look for the "child" object
var MonGroup=op->GetDown() ;
if (MonGroup) return; // if there is, we exit the coffee script
// else we create this object
MonGroup=new(PrimitiveObject) ;
MonGroup->SetName("My Object");
MonGroup->SetPrimitiveType(PRIMITIVE_CUBE);
doc->InsertObject(MonGroup,op,NULL);
Refresh(doc); // update
// 2 - Does the "BlakScreen" Material exist ?
var matiere=doc -> FindMaterial("BlackScreen") ;
if (!matiere)
{
matiere = new(Material) ;
matiere -> SetName ("BlackScreen");
doc ->InsertMaterial (matiere,NULL) ;
matiere -> Update () ;
}
var MonMark=matiere->GetMarker();// We get the material marker
// 3 - Apply the TextureTag on the Cube object
var MonTag = new(TextureTag);
MonGroup->InsertTag(MonTag,NULL);
MonGroup->Message(MSG_UPDATE); // IMPORTANT !!!
// 4 - TextureTag configuration
MonTag->SetMaterial(MonMark);
Refresh(doc); // Update
}