# Export to obj and reimport. In addition material collections for the objects # are saved and loaded to keep the material settings intact - so Poser 6+ only. # SAVE YOUR SCENE BEFORE RUNNING THIS SCRIPT! USE THIS SCRIPT ON A COPY OF YOUR # WORK! EVERY OBJECT OF THE SCENE WILL BE REPLACED BY A NEW OBJECT! # Will export/import the current frame. # Feel free to improve the script, like making multiframe work :-) # - Dizzi #------------------------------------------------------------------------------- # Set Poser Frame Numbers (1-x) for start and endframe / doesn't work #frameFrom=3 #frameTo=4 # and also set the temporary directory where the obj and mc6 are stored tempDir="C:\\temp\\" # nothing to do down here frameFrom=scene.Frame frameTo=scene.Frame multiframe=0 #if (frameFrom-frameTo)==0: # multiframe=1 global exportFigure global exportActor def CBFigure(actor): # The callback routine if actor.IsBodyPart()==1 and actor.ItsFigure().InternalName()==exportFigure.InternalName(): return 1 else: return 0 def CBActor(actor): # The callback routine if actor.InternalName()==exportActor.InternalName(): return 1 else: return 0 scene = poser.Scene() imExObject = scene.ImExporter() #scene.SetFrame(frameFrom) exoptions = imExObject.ExportOptions("obj", None) exoptions[poser.kExOptCodeUSEINTERNALNAMES] = 0 exoptions[poser.kExOptCodeFIRSTFRAME] = frameFrom exoptions[poser.kExOptCodeLASTFRAME] = frameTo exoptions[poser.kExOptCodeMULTIFRAME] = multiframe exoptions[poser.kExOptCodeWELDSEAMS] = 1 exoptions[poser.kExOptCodeASMORPHTARGET] = 0 exoptions[poser.kExOptCodeBODYPARTNAMESINPOLYGROUPS] = 0 exoptions[poser.kExOptCodeFIGNAMESINGROUPS] = 0 exoptions[poser.kExOptCodeEXISTINGGROUPSINPOLYGROUPS] = 0 imoptions = imExObject.ImportOptions("obj", None) imoptions[poser.kImOptCodeMAKEPOLYNORMSCONSISTENT] = 1 imoptions[poser.kImOptCodeOFFSETX] = 0.0 imoptions[poser.kImOptCodeOFFSETY] = 0.0 imoptions[poser.kImOptCodeOFFSETZ] = 0.0 imoptions[poser.kImOptCodeFLIPUTEXTCOORDS] = 0 imoptions[poser.kImOptCodeFLIPVTEXTCOORDS] = 0 imoptions[poser.kImOptCodeWELDIDENTICALVERTS] = 0 imoptions[poser.kImOptCodeCENTERED] = 0 imoptions[poser.kImOptCodePERCENTFIGSIZE] = 0.0 imoptions[poser.kImOptCodeFLIPNORMS] = 0 imoptions[poser.kImOptCodePLACEONFLOOR] = 0 print "Exporting and importing in Wavefront .obj format to "+tempDir+"..." for actor in scene.Actors(): if not (actor.IsBase() or actor.IsBodyPart() or actor.IsDeformer() or actor.IsZone() or actor.IsLight() or actor.IsCamera()) and actor.Name().count("Remote")==0 and actor.Name().count("CenterOfMass")==0 and not actor.Name()=='FocusDistanceControl' and not actor.Name()=='GROUND': exportActor=actor exportActorName=exportActor.Name() print 'Exporting '+exportActorName # export prop and import again -- acts as unparent... imExObject.Export('obj', 'File Format Wavefront', tempDir+exportActorName+'.obj', exoptions, CBActor) for curMat in exportActor.Materials(): curMat.SetSelected(1) exportActor.SaveMaterialCollection(tempDir+exportActorName+'.mc6') try: print 'Deleting original '+exportActorName exportActor.Delete() print 'Importing '+exportActorName imExObject.Import('obj', 'File Format Wavefront', tempDir+exportActorName+'.obj', imoptions) newactor=scene.Actor(exportActorName) print 'Loading mats for '+newactor.Name() newactor.LoadMaterialCollection(tempDir+exportActorName+'.mc6') except: print ('error loading '+exportActorName+'.obj') for figure in scene.Figures(): exportFigure=figure print 'Exporting '+exportFigure.Name() imExObject.Export('obj', 'File Format Wavefront', tempDir+figure.Name()+'.obj', exoptions, CBFigure) for curMat in figure.Materials(): curMat.SetSelected(1) figure.ParentActor().SaveMaterialCollection(tempDir+figure.Name()+'.mc6') print 'Importing '+exportFigure.Name() imExObject.Import('obj', 'File Format Wavefront', tempDir+figure.Name()+'.obj', imoptions) newactor=scene.Actor(figure.Name()) newactor.LoadMaterialCollection(tempDir+figure.Name()+'.mc6') for figure in scene.Figures(): print 'Deleting '+figure.Name() scene.SelectFigure(figure) scene.DeleteCurrentFigure() print 'Done!'