
import c4d
from c4d import gui, plugins, utils, bitmaps, storage
import os


PLUGIN_ID = 1028484

class Load(c4d.plugins.CommandData):
    dialog = None
    def Execute(self, doc):
		doc = c4d.documents.GetActiveDocument()
		dir, f = os.path.split(__file__)
		testdir =dir
		testdir,end = os.path.split(testdir)
		testdir,end = os.path.split(testdir)
		
		if len(end) !=	7:		
			filename = "InstallFail.c4d"	
		
		elif (c4d.GeGetVersionType() == c4d.VERSIONTYPE_STUDIO):
		
			 filename = "TransformStudio.c4d"	
		
		else:
		
			 filename = "TransformBroadcast.c4d"
		
		path = os.path.join(dir, "res",filename)
		if self.dialog is None:
			   c4d.documents.MergeDocument(doc, path ,c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS)
		
			   c4d.EventAdd()
			   obj =  doc.SearchObject("Transform")
			   obj[c4d.ID_USERDATA,38] =True
		return False
if __name__ == "__main__":
     bmp = bitmaps.BaseBitmap()
     dir, f = os.path.split(__file__)
     fn = os.path.join(dir, "res", "icon.tif")
     bmp.InitWith(fn)
     c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="Transform",
                                      help="GSG Transform Tool",info=0,
                                        dat=Load(), icon=bmp)
