def endExport(mainDialog,exportData):        
    #mainHelpers.deleteCopiedMeshes(exportData.allMeshObjects)
    if exportData is not None:
        if len(exportData.AWDerrorObjects)>0:  
            newMessage=c4d.plugins.GeLoadString(ids.ERRORMESSAGE)+"\n"
            for errorMessage in exportData.AWDerrorObjects:
                newMessage+=c4d.plugins.GeLoadString(errorMessage.errorID)
                if errorMessage.errorData!=None:
                    newMessage+="\n\n"+str(c4d.plugins.GeLoadString(ids.ERRORMESSAGEOBJ))+" = "+str(errorMessage.errorData)
            c4d.gui.MessageDialog(newMessage)
            if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True:  
                exportData=None
                c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
                c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
                c4d.EventAdd(c4d.EVENT_ANIMATE) 
                mainDialog.Close()
                return True  
            exportData=None
            c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
            c4d.EventAdd(c4d.EVENT_ANIMATE) 
            return True  
        if len(exportData.AWDwarningObjects)>0:  
            newMessage=c4d.plugins.GeLoadString(ids.WARNINGMESSAGE)+"\n"
            for errorMessage in exportData.AWDwarningObjects:
                newMessage+=c4d.plugins.GeLoadString(errorMessage.errorID)
                if errorMessage.errorData!=None:
                    newMessage+="AWDWarningObject: "+str(errorMessage.errorData)
            print "Warning "+str(newMessage)
            if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True:  
                exportData=None
                c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
                c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
                c4d.EventAdd(c4d.EVENT_ANIMATE) 
                mainDialog.Close()    
                return True  
        if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True and exportData.cancel!=True:  
            exportData=None
            c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
            c4d.EventAdd(c4d.EVENT_ANIMATE) 
            mainDialog.Close()
            return True  
    exportData=None
    c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
    c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
    c4d.EventAdd(c4d.EVENT_ANIMATE) 
    maindialogHelpers.enableAll(mainDialog,True)
    #print c4d.plugins.GeLoadString(ids.SUCCESSMESSAGE)
    mainHelpers.updateCanvas(mainDialog,exportData)
    c4d.EventAdd(c4d.EVENT_ANIMATE) 
    mainDialog.SetTimer(0)   
def printErrors(mainDialog,exportData):  
    if len(exportData.AWDerrorObjects)>0:  
        maindialogHelpers.enableAll(mainDialog,True)
        newMessage=c4d.plugins.GeLoadString(ids.ERRORMESSAGE)+"\n"
        for errorMessage in exportData.AWDerrorObjects:
            newMessage+=c4d.plugins.GeLoadString(errorMessage.errorID)
            if errorMessage.errorData!=None:
                newMessage+="\n\n"+str(c4d.plugins.GeLoadString(ids.ERRORMESSAGEOBJ))+" = "+str(errorMessage.errorData)
        c4d.gui.MessageDialog(newMessage)
        exportData=None
        if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True:  
            exportData=None
            c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
            c4d.EventAdd(c4d.EVENT_ANIMATE) 
            mainDialog.Close()
        c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
        c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
        c4d.EventAdd(c4d.EVENT_ANIMATE)  
        exportData=None  
        return False   
    return True	
def startExport(mainDialog,doc):   
    exportData=classMainScene.mainScene(doc,mainDialog)         # create a new "mainScene". this class will store all the data collected for export
        
    #exportData.doc.SetMode(11)#set EditMode to 11 (Model-Mode) - otherwise the triangulate method will only affect the selected polygons!     
    objectsToExport=exportData.doc.GetObjects()                             # get a list of all objects in the scene
    if len(objectsToExport)==0:                                             # if no object is in the scene:
        if exportData.unusedMats==False:                                        # if no unsued materials should be exported:
            newError=classesHelper.AWDerrorObject(ids.ERRORMESSAGE2,None)           # create a new errorObject
            exportData.AWDerrorObjects.append(newError)                             # append the new errorObject to the errorlist, so it will be displayed at the end of export process 
            return exportData                                                       # return from function
        if exportData.unusedMats==True:                                         # if unused materials should be exported:
            exportData.allc4dMaterials=doc.GetMaterials()                           # get a list of all materials
            if len(exportData.allc4dMaterials)==0:                                  # if no material was found:
                newError=classesHelper.AWDerrorObject(ids.ERRORMESSAGE2,None)           # create a new errorObject
                exportData.AWDerrorObjects.append(newError)                             # append the new errorObject to the errorlist, so it will be displayed at the end of export process 
                return exportData                                                       # return from function
    
    exportData.objList=objectsToExport
    
    exportData.allStatusLength=2    # used to calculate the progress-bar
    exportData.allStatus=1                                      # used to calculate the progress-bar
    exportData.status=1   
    datei=c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING, "save as *.AWD", "awd")
    if datei is None:     
        newError=classesHelper.AWDerrorObject(ids.ERRORMESSAGE2,None)           # create a new errorObject
        exportData.AWDerrorObjects.append(newError)                             # append the new errorObject to the errorlist, so it will be displayed at the end of export process 
        return None
    maindialogHelpers.enableAll(mainDialog,False)               # disable the all GUI-elements, so the user can not change anything while exporting 
    exportData.datei=datei
    # if this is executed, we know there is something to export!
    
    # create the MetaDataBlock
    newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(None,"",255)
    exportData.idCounter+=1
    newMetaDataBlock=classesAWDBlocks.MetaDataBlock(0,0)
    newMetaDataBlock.timestamp=0# to do
    newMetaDataBlock.encoder="AWDToolsC4D"
    newMetaDataBlock.encoderVersion="0.9"
    newMetaDataBlock.app="Cinema4D"
    newMetaDataBlock.appVersion="R13 / R14" # to do
    newAWDWrapperBlock.data=newMetaDataBlock
    newAWDWrapperBlock.tagForExport=True   
    exportData.allAWDBlocks.append(newAWDWrapperBlock)  
    
    # create a AWD-Material-Block for the C4D-Default-Color, in case some Objects have no Materials/ObjectColors Applied
    newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(None,"C4D-DefaultMaterial",81)
    defaultColor=exportData.doc[c4d.DOCUMENT_DEFAULTMATERIAL_COLOR]
    newAWDBlock=classesAWDBlocks.StandartMaterialBlock(exportData.idCounter,0,True)
    newAWDBlock.saveLookUpName="C4D-DefaultMat"
    exportData.allMatBlocks.append(newAWDBlock)
    defaultColorString="#"+str(defaultColor)
    exportData.colorMaterials[defaultColorString]=newAWDBlock
    newAWDBlock.matColor=[defaultColor.z*255,defaultColor.y*255,defaultColor.x*255,0]
    newAWDBlock.saveMatProps.append(1)
    newAWDBlock.isCreated=True
    newAWDWrapperBlock.data=newAWDBlock
    newAWDWrapperBlock.tagForExport=False 
    exportData.allAWDBlocks.append(newAWDWrapperBlock)  
    exportData.idCounter+=1
    
    # create a AWD-Material-Block for all the C4D-Materials in the scene, regardless if they will be exported or not. 
    for mat in exportData.allc4dMaterials:
        newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(mat,mat.GetName(),81)
        newAWDBlock=classesAWDBlocks.StandartMaterialBlock(exportData.idCounter,0,False)
        newAWDBlock.saveLookUpName=mat.GetName()
        newAWDBlock.name=mat.GetName()
        newAWDBlock.mat=mat
        mat.SetName(str(exportData.idCounter))
        exportData.idCounter+=1
        newAWDWrapperBlock.data=newAWDBlock
        newAWDWrapperBlock.tagForExport=False    
        exportData.allAWDBlocks.append(newAWDWrapperBlock)
        exportData.allMatBlocks.append(newAWDBlock) 	
    
    # create a AWD-Block for all Objects in the Scene (and their tags) regardless if they will be exported or not
    mainParseObjectToAWDBlock.createAllAWDBlocks(exportData,objectsToExport)
    
    # create a SceneBlock for all Objects that should be exported
    mainParseObjectToAWDBlock.createAllSceneBlocks(exportData,objectsToExport,exportData.defaultObjectSettings)
    
    exportData.allStatusLength=2+(10*int(exportData.animationCounter))+(10*len(exportData.allMeshObjects))# used to calculate the progress-bar
    exportData.allStatus=1                                      # used to calculate the progress-bar
    exportData.status=1                                         # used to calculate the progress-bar
    mainHelpers.updateCanvas(mainDialog,exportData)             # update the progress-bar
    mainSkeletonReader.createSkeletonBlocks(exportData.objList,exportData,mainDialog) 
    if mainDialog.GetBool(ids.CBOX_VANIMATION)==True:
        mainVertexAnimationReader.getVertexAnimationData(exportData.objList,exportData,mainDialog)
    exportData.status=2  
    mainHelpers.updateCanvas(mainDialog,exportData)
    return exportData         
Example #4
0
def startExport(mainDialog, doc):
    exportData = classMainScene.mainScene(
        doc, mainDialog
    )  # create a new "mainScene". this class will store all the data collected for export

    # not needed anymor ?
    #exportData.doc.SetMode(11)#set EditMode to 11 (Model-Mode) - otherwise the triangulate method will only affect the selected polygons!
    objectsToExport = exportData.doc.GetObjects(
    )  # get a list of all objects in the scene

    # check if there is anything to export
    if len(objectsToExport) == 0:  # if no object is in the scene:
        if exportData.unusedMats == False:  # if no unsued materials should be exported:
            newError = classesHelper.AWDerrorObject(
                ids.ERRORMESSAGE2, None)  # create a new errorObject
            exportData.AWDerrorObjects.append(
                newError
            )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
            return exportData  # return from function
        if exportData.unusedMats == True:  # if unused materials should be exported:
            exportData.allc4dMaterials = doc.GetMaterials(
            )  # get a list of all materials
            if len(exportData.allc4dMaterials
                   ) == 0:  # if no material was found:
                newError = classesHelper.AWDerrorObject(
                    ids.ERRORMESSAGE2, None)  # create a new errorObject
                exportData.AWDerrorObjects.append(
                    newError
                )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
                return exportData  # return from function
    exportData.objList = objectsToExport

    # calculate progressbar
    exportData.allStatusLength = 2  # used to calculate the progress-bar
    exportData.allStatus = 1  # used to calculate the progress-bar
    exportData.status = 1

    # open save as dialog
    datei = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING,
                                   "save as *.AWD", "awd")
    if datei is None:
        newError = classesHelper.AWDerrorObject(
            ids.ERRORMESSAGE2, None)  # create a new errorObject
        exportData.AWDerrorObjects.append(
            newError
        )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
        return None

    # disable the all GUI-elements, so the user can not change anything while exporting
    maindialogHelpers.enableAll(mainDialog, False)
    exportData.datei = datei

    # if this is executed, we know there is something to export!

    # create the MetaDataBlock
    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(None, "", 255)
    exportData.idCounter += 1
    newMetaDataBlock = classesAWDBlocks.MetaDataBlock(0, 0)
    newMetaDataBlock.timestamp = 0  # to do
    newMetaDataBlock.encoder = "AWDToolsC4D"
    newMetaDataBlock.encoderVersion = "0.9"
    newMetaDataBlock.app = "Cinema4D"
    newMetaDataBlock.appVersion = "R13 / R14"  # to do
    newAWDWrapperBlock.data = newMetaDataBlock
    newAWDWrapperBlock.tagForExport = True
    exportData.allAWDBlocks.append(newAWDWrapperBlock)

    # create a AWD-Material-Block for the C4D-Default-Color, in case some Objects have no Materials/ObjectColors Applied
    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(None,
                                                       "C4D-DefaultMaterial",
                                                       81)
    defaultColor = exportData.doc[c4d.DOCUMENT_DEFAULTMATERIAL_COLOR]
    newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
        exportData.idCounter, 0, True)
    newAWDBlock.saveLookUpName = "C4D-DefaultMat"
    exportData.allMatBlocks.append(newAWDBlock)
    defaultColorString = "#" + str(defaultColor)
    exportData.colorMaterials[defaultColorString] = newAWDBlock
    newAWDBlock.matColor = [
        defaultColor.z * 255, defaultColor.y * 255, defaultColor.x * 255, 0
    ]
    newAWDBlock.saveMatProps.append(1)
    newAWDBlock.isCreated = True
    newAWDWrapperBlock.data = newAWDBlock
    newAWDWrapperBlock.tagForExport = False
    exportData.allAWDBlocks.append(newAWDWrapperBlock)
    exportData.idCounter += 1

    # create a AWD-Material-Block for all the C4D-Materials in the scene, regardless if they will be exported or not.
    for mat in exportData.allc4dMaterials:
        newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(
            mat, mat.GetName(), 81)
        newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
            exportData.idCounter, 0, False)
        newAWDBlock.saveLookUpName = mat.GetName()
        newAWDBlock.name = mat.GetName()
        newAWDBlock.mat = mat
        mat.SetName(str(exportData.idCounter))
        exportData.idCounter += 1
        newAWDWrapperBlock.data = newAWDBlock
        newAWDWrapperBlock.tagForExport = False
        exportData.allAWDBlocks.append(newAWDWrapperBlock)
        exportData.allMatBlocks.append(newAWDBlock)

    # create a AWD-Block for all Objects in the Scene (and their tags) regardless if they will be exported or not
    mainParseObjectToAWDBlock.createAllAWDBlocks(exportData, objectsToExport)

    # create a SceneBlock for all Objects that should be exported
    mainParseObjectToAWDBlock.createAllSceneBlocks(
        exportData, objectsToExport, exportData.defaultObjectSettings)

    exportData.allStatusLength = 2 + (10 *
                                      int(exportData.animationCounter)) + (
                                          10 * len(exportData.allMeshObjects)
                                      )  # used to calculate the progress-bar
    exportData.allStatus = 1  # used to calculate the progress-bar
    exportData.status = 1  # used to calculate the progress-bar
    mainHelpers.updateCanvas(mainDialog, exportData)  # update the progress-bar
    mainSkeletonReader.createSkeletonBlocks(exportData.objList, exportData,
                                            mainDialog)
    if mainDialog.GetBool(ids.CBOX_VANIMATION) == True:
        mainVertexAnimationReader.getVertexAnimationData(
            exportData.objList, exportData, mainDialog)
    exportData.status = 2
    mainHelpers.updateCanvas(mainDialog, exportData)
    return exportData
Example #5
0
def endExport(mainDialog, exportData):
    #mainHelpers.deleteCopiedMeshes(exportData.allMeshObjects)
    if exportData is not None:
        if len(exportData.AWDerrorObjects) > 0:
            newMessage = c4d.plugins.GeLoadString(ids.ERRORMESSAGE) + "\n"
            for errorMessage in exportData.AWDerrorObjects:
                newMessage += c4d.plugins.GeLoadString(errorMessage.errorID)
                if errorMessage.errorData != None:
                    newMessage += "\n\n" + str(
                        c4d.plugins.GeLoadString(
                            ids.ERRORMESSAGEOBJ)) + " = " + str(
                                errorMessage.errorData)
            c4d.gui.MessageDialog(newMessage)
            if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True:
                exportData = None
                c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD
                              | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK)
                c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
                c4d.EventAdd(c4d.EVENT_ANIMATE)
                mainDialog.Close()
                return True
            exportData = None
            c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD
                          | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK)
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
            c4d.EventAdd(c4d.EVENT_ANIMATE)
            return True
        if len(exportData.AWDwarningObjects) > 0:
            newMessage = c4d.plugins.GeLoadString(ids.WARNINGMESSAGE) + "\n"
            for errorMessage in exportData.AWDwarningObjects:
                newMessage += c4d.plugins.GeLoadString(errorMessage.errorID)
                if errorMessage.errorData != None:
                    newMessage += "AWDWarningObject: " + str(
                        errorMessage.errorData)
            print "Warning " + str(newMessage)
            if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True:
                exportData = None
                c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD
                              | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK)
                c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
                c4d.EventAdd(c4d.EVENT_ANIMATE)
                mainDialog.Close()
                return True
        if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT
                              ) == True and exportData.cancel != True:
            exportData = None
            c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD
                          | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK)
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
            c4d.EventAdd(c4d.EVENT_ANIMATE)
            mainDialog.Close()
            return True
    exportData = None
    c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD
                  | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK)
    c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
    c4d.EventAdd(c4d.EVENT_ANIMATE)
    maindialogHelpers.enableAll(mainDialog, True)
    #print c4d.plugins.GeLoadString(ids.SUCCESSMESSAGE)
    mainHelpers.updateCanvas(mainDialog, exportData)
    c4d.EventAdd(c4d.EVENT_ANIMATE)
    mainDialog.SetTimer(0)
Example #6
0
    def Command(self, id, msg):  
        global workerThread,exportData             
        mainHelpers.updateCanvas(self,exportData)       
        
        if id == ids.BTN_RECORDVERTEXANIMATION:        # Save with assets was hit: 
            doc=c4d.documents.GetActiveDocument()
            mainHelpers.bakeVertexAnimation(doc)
            
        if id == ids.BTN_CHECKSKELETON:                 # check Skeleton was hit:                
            op=mainHelpers.checkforValidSelectedSkeleton()
            if op is not None:  
                doc=c4d.documents.GetActiveDocument()
                doc.StartUndo()                     # Start undo support
                doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) # Support redo the insert operation
                checkSkeleton=mainSkeletonHelper.SkeletonHelper(op) # we create a SkeletonHelper-Object to check if the selected object is a valid skeleton
                doc.EndUndo()                       # Do not forget to close the undo support 
                return True
            c4d.gui.MessageDialog("To use this function, you need to select one Object that has Child-Objects\n,or one SkeletonTag,or one SkeletonAnimationTag")   
        if id == ids.BTN_CREATESKELETONANIMATION:                 # check Skeleton was hit:                
            op=mainHelpers.checkforValidSelectedSkeleton()
            if op is not None:        
                mainHelpers.copySkeletonAndApplySkeletonAnimation(op) # we create a SkeletonHelper-Object to check if the selected object is a valid skeleton
                return True
            c4d.gui.MessageDialog("To use this function, you need to select one SkeletonTag, or one Object that has a SkeletonTag applied!")  
                
        if id == ids.BTN_SAVEWITHASSETS:        # Save with assets was hit: 
            c4d.CallCommand(12255)                  # we just call the command "Save C4D-Scene with Assets"           
                    
        if id == ids.BTN_CANCEL:                # cancel Button was hit: cancel export process:   
            print "User cancelled the export-process"
            self.SetTimer(0)
            self.workerAction=None
            if workerThread is not None:
                if workerThread.IsRunning()==True:
                    workerThread.End()
            exportData=None
            mainHelpers.updateCanvas(self,exportData)
            maindialogHelpers.enableAll(self,True)
            return True            
       
        if id == ids.BTN_EXPORT:             # export button was hit: start export process:
            #check if a valid C4D scene is active, if not we return with error-message
            doc=c4d.documents.GetActiveDocument()
            self.workerAction="exporting"
            if doc==None:
                newMessage=c4d.plugins.GeLoadString(ids.STATUSMESSAGE1)
                c4d.gui.MessageDialog(newMessage)
                return True
            if doc.GetDocumentPath()==None or doc.GetDocumentPath()=="":
                newMessage=c4d.plugins.GeLoadString(ids.STATUSMESSAGE1)
                c4d.gui.MessageDialog(newMessage)
                return True
            
            exportData=mainExporter.startExport(self,doc)       # start the export-process thats done in the c4d-main-Thread                     
            if exportData is not None:                            # if the exportData object is still alive, no error has occured
                mainHelpers.printErrors(self,exportData)                              # if any errors occured, print them out and delete the "exportData"-object
                workerThread  = WorkerThread()                  # recreated the workerThread (open a new c4d-thread for the heavy mesh-processing)
                workerThread.Start()                            # start the workerThread
                self.SetTimer(20)                               # start the timer-function to monitor the workerThread
            if exportData is None:                            # if the export data is not alive, a error has occured
                self.SetTimer(0)                                # stop the timer-function
              
        if id == ids.CBOX_ANIMATION: 
            self.animationBool=self.GetBool(ids.CBOX_ANIMATION)
            maindialogHelpers.setUI(self)  
        if id == ids.CBOX_VANIMATION: 
            self.vanimationBool=self.GetBool(ids.CBOX_VANIMATION)
            maindialogHelpers.setUI(self) 
        if id == ids.CBOX_CLOSEAFTEREXPORT: 
            self.closeAfter=self.GetBool(ids.CBOX_CLOSEAFTEREXPORT)
        if id == ids.CBOX_UNUSEDMATS: 
            self.unusedMats=self.GetBool(ids.CBOX_UNUSEDMATS)
            
        if id == ids.CBOX_STREAMING: 
            self.streaming=self.GetBool(ids.CBOX_STREAMING)
            if self.streaming==True:
                self.SetBool(ids.CBOX_COMPRESSED,False)
                self.compressData=False
            maindialogHelpers.setUI(self)  
                
        if id == ids.CBOX_COMPRESSED: 
            self.compressData=self.GetBool(ids.CBOX_COMPRESSED)
            if self.compressData==True:
                self.SetBool(ids.CBOX_STREAMING,False)
                self.streaming=False
            maindialogHelpers.setUI(self)  
            
        if id == ids.CBOX_DEBUG:  
            self.debug=self.GetBool(ids.CBOX_DEBUG)
            
        if id == ids.CBOX_OPENPREFAB:  
            self.openInPreFab=self.GetBool(ids.CBOX_OPENPREFAB)
            
        if id == ids.COMBO_RANGE: 
            self.animationRange=self.GetLong(ids.COMBO_RANGE)
            maindialogHelpers.setUI(self)
            
        if id == ids.COMBO_TEXTURESMODE: 
            maindialogHelpers.setValues(self)   
            maindialogHelpers.setUI(self)
           
        if id == ids.MENU_ABOUT_ABOUT: 

            pass#dlg = AboutDialog()
            #DLG_TYPE_MODAL = > synchronous dialog
            #DLG_TYPE_ASYNC = > asynchronous dialogs
            #dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=300)
            
        if id == ids.MENU_ABOUT_HELP: 
            realPath= os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
            helpPath=os.path.join(realPath, "res",  "Help","index.html")
            c4d.storage.GeExecuteFile(helpPath)
            print helpPath
            #pass#dlg = HelpDialog()
            #DLG_TYPE_MODAL = > synchronous dialog
            #DLG_TYPE_ASYNC = > asynchronous dialogs
            #dlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=400, defaulth=400)
            
        if id == ids.MENU_CHECKFORUPDATE: 
            realPath= os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
            helpPath=os.path.join(realPath, "res",  "awayextensionsc4dversion.xml")
            versionThis=maindialogHelpers.loadVersionFile(helpPath)
            versionWeb=maindialogHelpers.loadVersionFilefromNet()
            if versionThis=="" or versionWeb=="":
                return
            if versionThis!=versionWeb:
                message="Your Version is not up to date\n"
                message+="Go to \nhttps://github.com/awaytools/AwayExtensions-C4D\n and get the new version\n\n"
                message+="Your version = "+str(versionThis)+"\n"
                message+="Latest version = "+str(versionWeb)+"\n"
            if versionThis==versionWeb:
                message="Your Version is up to date\n"
            c4d.gui.MessageDialog(message)
            
        maindialogHelpers.setValues(self)   
        return True  
Example #7
0
    def Command(self, id, msg):
        global workerThread, exportData
        mainHelpers.updateCanvas(self, exportData)

        if id == ids.BTN_RECORDVERTEXANIMATION:  # Save with assets was hit:
            doc = c4d.documents.GetActiveDocument()
            mainHelpers.bakeVertexAnimation(doc)

        if id == ids.BTN_CHECKSKELETON:  # check Skeleton was hit:
            op = mainHelpers.checkforValidSelectedSkeleton()
            if op is not None:
                doc = c4d.documents.GetActiveDocument()
                doc.StartUndo()  # Start undo support
                doc.AddUndo(c4d.UNDOTYPE_CHANGE,
                            op)  # Support redo the insert operation
                checkSkeleton = mainSkeletonHelper.SkeletonHelper(
                    op
                )  # we create a SkeletonHelper-Object to check if the selected object is a valid skeleton
                doc.EndUndo()  # Do not forget to close the undo support
                return True
            c4d.gui.MessageDialog(
                "To use this function, you need to select one Object that has Child-Objects\n,or one SkeletonTag,or one SkeletonAnimationTag"
            )
        if id == ids.BTN_CREATESKELETONANIMATION:  # check Skeleton was hit:
            op = mainHelpers.checkforValidSelectedSkeleton()
            if op is not None:
                mainHelpers.copySkeletonAndApplySkeletonAnimation(
                    op
                )  # we create a SkeletonHelper-Object to check if the selected object is a valid skeleton
                return True
            c4d.gui.MessageDialog(
                "To use this function, you need to select one SkeletonTag, or one Object that has a SkeletonTag applied!"
            )

        if id == ids.BTN_SAVEWITHASSETS:  # Save with assets was hit:
            c4d.CallCommand(
                12255)  # we just call the command "Save C4D-Scene with Assets"

        if id == ids.BTN_CANCEL:  # cancel Button was hit: cancel export process:
            print "User cancelled the export-process"
            self.SetTimer(0)
            self.workerAction = None
            if workerThread is not None:
                if workerThread.IsRunning() == True:
                    workerThread.End()
            exportData = None
            mainHelpers.updateCanvas(self, exportData)
            maindialogHelpers.enableAll(self, True)
            return True

        if id == ids.BTN_EXPORT:  # export button was hit: start export process:
            #check if a valid C4D scene is active, if not we return with error-message
            doc = c4d.documents.GetActiveDocument()
            self.workerAction = "exporting"
            if doc == None:
                newMessage = c4d.plugins.GeLoadString(ids.STATUSMESSAGE1)
                c4d.gui.MessageDialog(newMessage)
                return True
            if doc.GetDocumentPath() == None or doc.GetDocumentPath() == "":
                newMessage = c4d.plugins.GeLoadString(ids.STATUSMESSAGE1)
                c4d.gui.MessageDialog(newMessage)
                return True

            exportData = mainExporter.startExport(
                self, doc
            )  # start the export-process thats done in the c4d-main-Thread
            if exportData is not None:  # if the exportData object is still alive, no error has occured
                mainHelpers.printErrors(
                    self, exportData
                )  # if any errors occured, print them out and delete the "exportData"-object
                workerThread = WorkerThread(
                )  # recreated the workerThread (open a new c4d-thread for the heavy mesh-processing)
                workerThread.Start()  # start the workerThread
                self.SetTimer(
                    20)  # start the timer-function to monitor the workerThread
            if exportData is None:  # if the export data is not alive, a error has occured
                self.SetTimer(0)  # stop the timer-function

        if id == ids.CBOX_ANIMATION:
            self.animationBool = self.GetBool(ids.CBOX_ANIMATION)
            maindialogHelpers.setUI(self)
        if id == ids.CBOX_VANIMATION:
            self.vanimationBool = self.GetBool(ids.CBOX_VANIMATION)
            maindialogHelpers.setUI(self)
        if id == ids.CBOX_CLOSEAFTEREXPORT:
            self.closeAfter = self.GetBool(ids.CBOX_CLOSEAFTEREXPORT)
        if id == ids.CBOX_UNUSEDMATS:
            self.unusedMats = self.GetBool(ids.CBOX_UNUSEDMATS)

        if id == ids.CBOX_STREAMING:
            self.streaming = self.GetBool(ids.CBOX_STREAMING)
            if self.streaming == True:
                self.SetBool(ids.CBOX_COMPRESSED, False)
                self.compressData = False
            maindialogHelpers.setUI(self)

        if id == ids.CBOX_COMPRESSED:
            self.compressData = self.GetBool(ids.CBOX_COMPRESSED)
            if self.compressData == True:
                self.SetBool(ids.CBOX_STREAMING, False)
                self.streaming = False
            maindialogHelpers.setUI(self)

        if id == ids.CBOX_DEBUG:
            self.debug = self.GetBool(ids.CBOX_DEBUG)

        if id == ids.CBOX_OPENPREFAB:
            self.openInPreFab = self.GetBool(ids.CBOX_OPENPREFAB)

        if id == ids.COMBO_RANGE:
            self.animationRange = self.GetLong(ids.COMBO_RANGE)
            maindialogHelpers.setUI(self)

        if id == ids.COMBO_TEXTURESMODE:
            maindialogHelpers.setValues(self)
            maindialogHelpers.setUI(self)

        if id == ids.MENU_ABOUT_ABOUT:

            pass  #dlg = AboutDialog()
            #DLG_TYPE_MODAL = > synchronous dialog
            #DLG_TYPE_ASYNC = > asynchronous dialogs
            #dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=300)

        if id == ids.MENU_ABOUT_HELP:
            realPath = os.path.abspath(
                os.path.join(os.path.dirname(__file__), ".."))
            helpPath = os.path.join(realPath, "res", "Help", "index.html")
            c4d.storage.GeExecuteFile(helpPath)
            print helpPath
            #pass#dlg = HelpDialog()
            #DLG_TYPE_MODAL = > synchronous dialog
            #DLG_TYPE_ASYNC = > asynchronous dialogs
            #dlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=400, defaulth=400)

        if id == ids.MENU_CHECKFORUPDATE:
            realPath = os.path.abspath(
                os.path.join(os.path.dirname(__file__), ".."))
            helpPath = os.path.join(realPath, "res",
                                    "awayextensionsc4dversion.xml")
            versionThis = maindialogHelpers.loadVersionFile(helpPath)
            versionWeb = maindialogHelpers.loadVersionFilefromNet()
            if versionThis == "" or versionWeb == "":
                return
            if versionThis != versionWeb:
                message = "Your Version is not up to date\n"
                message += "Go to \nhttps://github.com/awaytools/AwayExtensions-C4D\n and get the new version\n\n"
                message += "Your version = " + str(versionThis) + "\n"
                message += "Latest version = " + str(versionWeb) + "\n"
            if versionThis == versionWeb:
                message = "Your Version is up to date\n"
            c4d.gui.MessageDialog(message)

        maindialogHelpers.setValues(self)
        return True