C4D Scripts

On this page I’ll post any scripts I made with C4D for personal work flow improvements. If you copy the code please pay attention to every white space and its position. For your convenience the scripts with icon as a compiled file can be downloaded and put into your: “.\library\scripts” folder in Your Cinema 4D folder.

CAD Import All in One Solution

cad_clean

CAD cleanup_v1.0

Center to Parent
This script just does what good old Acenter plugin did. Since Acenter is no longer available for download and I needed it for Cinema R9.6 I made this little script.

Be aware that this functionality is already included in Cinema R10.
NEW Version !

if (op!=NULL)
{
	var parent=op->GetUp();
	if (!(parent)) return;
	doc->StartUndo();
	doc->AddUndo(UNDO_OBJECT,op);

	var pmatrix=parent->GetMg(); //get the global Matrix
	var parent_positon = pmatrix->GetV0();  // get the position of the matrix
	var parent_rotation_x = pmatrix->GetV1(); // get the rotation of the matrix
	var parent_rotation_y = pmatrix->GetV2();
	var parent_rotation_z = pmatrix->GetV3();

	var child_scale=op->GetScale(); // get the childscale 

	var newmatrix=new(Matrix); // create a new matrix

	newmatrix->SetV0(parent_positon); //write into the new matrix
	newmatrix->SetV1(parent_rotation_x);
	newmatrix->SetV2(parent_rotation_y);
	newmatrix->SetV3(parent_rotation_z);

	op->SetMg(newmatrix); // set the new written matrix
	op->SetScale(child_scale); // reset the child scale

doc->EndUndo();
}

C4D Script File: Center to Parent 1.2

Toggle Grid On/OFF

Toggles the Grid Display in active View ON/OFF.

doc->GetActiveBaseDraw()#BASEDRAW_DISPLAYFILTER_GRID = !doc->GetActiveBaseDraw()#BASEDRAW_DISPLAYFILTER_GRID;

C4D Script File: Toggle Grid On/OFF

Toggle Saveframe

Toggles the Saveframe Display in active 3D View ON/OFF.

doc->GetActiveBaseDraw()#BASEDRAW_DATA_SHOWSAFEFRAME = !doc->GetActiveBaseDraw()#BASEDRAW_DATA_SHOWSAFEFRAME;

C4D Script File: Toggle Saveframe

Toggle Background Image

Toggles the Background Image Display in active 2D view ON/OFF.

doc->GetActiveBaseDraw()#BASEDRAW_DATA_SHOWPICTURE = !doc->GetActiveBaseDraw()#BASEDRAW_DATA_SHOWPICTURE;

C4D Script File: Toggle Background Image

Delete UVW & Texture Tags

Deletes UVW & Texture Tags for saving Harddiskspace on heavy CAD imports.

 getNextObject(op)
 {
 	if (!op) return null;
 	if (op->GetDown()) return op->GetDown();
 	while (!op->GetNext() && op->GetUp()) op = op->GetUp();
 	return op->GetNext();
 }

 main(doc,op)
 {
	CallCommand(13957); //Clear the Console

 	//Get the first object in the document
 	var myobject = doc->GetFirstObject();
	var deleteme;
 	if (!myobject) return false;

 	doc->StartUndo();

 	while (myobject)
 	{
	var tag = myobject->GetFirstTag();
		while (tag)
		{
	  	tag->DelBit(BIT_ACTIVE);
	  	if (tag->IsInstanceOf(Tuvw) || tag->IsInstanceOf(Ttexture)) //check if UVW or Texturetag
	  		{
			deleteme=tag; //save the active tag to another variable
			tag = tag->GetNext(); //go to next tage bevore we delete the active one
			doc->AddUndo(UNDO_DELETE, deleteme); // set an internal undo record for the following specific action
			deleteme->Remove();				//delete the saved tag
	  		}
		else{
	  		tag = tag->GetNext();
		}
	}
	myobject = getNextObject(myobject);
}
CallCommand(12168); //delete unused Materials
CallCommand(100004760); //remove unused Layers
return true;
doc->EndUndo();
}

C4D Script File: Delete UVW & Texture Tags


That’s it for now, please feel free to report any bugs. You may also hit the donation button if you want to support me.