Ejemplo n.º 1
0
    def _importAlembic(self, filePath, importSettings, *args, **kwargs):
        # Set Alembic Options according to the Max Version:
        v = rt.maxVersion()[0]
        maxImp_abc = importSettings["alembicImportMax"]

        if v > 17000:  # Alembic export is not supported before 3ds Max 2016
            if rt.pluginManager.loadclass(rt.Alembic_Export):
                if 18000 <= v < 21000:  # between versions 2016 - 2018
                    rt.AlembicImport.CoordinateSystem = rt.Name(
                        maxImp_abc["CoordinateSystem"])
                    rt.AlembicImport.CacheTimeRange = rt.Name(
                        maxImp_abc["AnimTimeRange"])
                    rt.AlembicImport.ShapeName = maxImp_abc["ShapeSuffix"]
                    rt.AlembicImport.ImportToRoot = maxImp_abc["ImportToRoot"]
                    rt.AlembicImport.FitTimeRange = maxImp_abc["FitTimeRange"]
                    rt.AlembicImport.SetStartTime = maxImp_abc["SetStartTime"]
                    rt.AlembicExport.StepFrameTime = maxImp_abc[
                        "SamplesPerFrame"]

                elif v >= 21000:  # version 2019 and up
                    rt.AlembicImport.CoordinateSystem = rt.Name(
                        maxImp_abc["CoordinateSystem"])
                    rt.AlembicImport.AnimTimeRange = rt.Name(
                        maxImp_abc["AnimTimeRange"])
                    rt.AlembicImport.ShapeSuffix = maxImp_abc["ShapeSuffix"]
                    rt.AlembicImport.SamplesPerFrame = maxImp_abc[
                        "SamplesPerFrame"]
                    rt.AlembicImport.Hidden = maxImp_abc["Hidden"]
                    rt.AlembicImport.UVs = maxImp_abc["UVs"]
                    rt.AlembicImport.Normals = maxImp_abc["Normals"]
                    rt.AlembicImport.VertexColors = maxImp_abc["VertexColors"]
                    rt.AlembicImport.ExtraChannels = maxImp_abc[
                        "ExtraChannels"]
                    rt.AlembicImport.Velocity = maxImp_abc["Velocity"]
                    rt.AlembicImport.MaterialIDs = maxImp_abc["MaterialIDs"]
                    rt.AlembicImport.Visibility = maxImp_abc["Visibility"]
                    rt.AlembicImport.LayerName = maxImp_abc["LayerName"]
                    rt.AlembicImport.MaterialName = maxImp_abc["MaterialName"]
                    rt.AlembicImport.ObjectID = maxImp_abc["ObjectID"]
                    rt.AlembicImport.CustomAttributes = maxImp_abc[
                        "CustomAttributes"]

                # Export
                rt.importFile(filePath,
                              rt.Name("NoPrompt"),
                              using=rt.Alembic_Import)
                return True

            else:
                rt.messageBox("Alembic Plugin cannot be initialized. Skipping",
                              title="Alembic not supported")
                return False
        else:
            rt.messageBox(
                "There is no alembic support for this version. Skipping",
                title="Alembic not supported")
            return False
Ejemplo n.º 2
0
def import_obj_file(file_path, force=True, **kwargs):
    """
    Imports OBJ file into current DCC scene
    :param file_path: str
    :param force: bool
    :param kwargs: keyword arguments
    :return:
    """

    if force:
        return rt.importFile(file_path,
                             rt.readValue(rt.StringStream('#noPrompt')),
                             using='OBJIMP')
    else:
        return rt.importFile(file_path, using='OBJIMP')
Ejemplo n.º 3
0
 def _importFbx(self, filePath, importSettings, *args, **kwargs):
     if rt.pluginManager.loadclass(rt.FBXIMP):
         maxImp_fbx = importSettings["fbxImportMax"]
         # Set FBX Options
         for item in maxImp_fbx.items():
             rt.FBXImporterSetParam(rt.Name(item[0]), item[1])
         rt.FBXImporterSetParam(rt.Name("UpAxis"), "Z")
         try:
             rt.importFile(filePath, rt.Name("NoPrompt"), using=rt.FBXIMP)
             return True
         except:
             msg = "Cannot import FBX file for unknown reason. Skipping import"
             rt.messageBox(msg, title='Info')
             return False
     else:
         msg = "FBX Plugin cannot be initialized. Skipping import"
         rt.messageBox(msg, title='Info')
         return False
Ejemplo n.º 4
0
def import_file(file_path, force=True, **kwargs):
    """
    Imports given file into current DCC scene
    :param file_path: str
    :param force: bool
    :return:
    """

    return rt.importFile(file_path, noPrompt=force)
Ejemplo n.º 5
0
def import_fbx_file(file_path, force=True, **kwargs):
    """
    Imports FBX file into current DCC scene
    :param file_path: str
    :param force: bool
    :param kwargs: keyword arguments
    :return:
    """

    skin = kwargs.get('skin', True)
    animation = kwargs.get('animation', True)

    rt.FBXExporterSetParam("Mode", rt.readvalue(rt.StringStream('#create')))
    # rt.FBXExporterSetParam("Skin", skin)
    # rt.FBXExporterSetParam("Animation", animation)

    if force:
        return rt.importFile(file_path,
                             rt.readValue(rt.StringStream('#noPrompt')))
    else:
        return rt.importFile(file_path)
Ejemplo n.º 6
0
 def _importObj(self, filePath, importSettings, *args, **kwargs):
     if rt.pluginManager.loadclass(rt.ObjExp):
         # Set OBJ Options
         maxImp_obj = importSettings["objImportMax"]
         iniPath_importSettings = rt.objImp.getIniName()
         rt.setINISetting(iniPath_importSettings, "General", "UseLogging",
                          maxImp_obj["UseLogging"])
         rt.setINISetting(iniPath_importSettings, "General", "ResetScene",
                          maxImp_obj["ResetScene"])
         rt.setINISetting(iniPath_importSettings, "General", "CurrObjColor",
                          maxImp_obj["CurrObjColor"])
         rt.setINISetting(iniPath_importSettings, "General",
                          "MapSearchPath", maxImp_obj["MapSearchPath"])
         rt.setINISetting(iniPath_importSettings, "Objects", "SingleMesh",
                          maxImp_obj["SingleMesh"])
         rt.setINISetting(iniPath_importSettings, "Objects",
                          "AsEditablePoly", maxImp_obj["AsEditablePoly"])
         rt.setINISetting(iniPath_importSettings, "Objects",
                          "Retriangulate", maxImp_obj["Retriangulate"])
         rt.setINISetting(iniPath_importSettings, "Geometry", "FlipZyAxis",
                          maxImp_obj["FlipZyAxis"])
         rt.setINISetting(iniPath_importSettings, "Geometry",
                          "CenterPivots", maxImp_obj["CenterPivots"])
         rt.setINISetting(iniPath_importSettings, "Geometry", "Shapes",
                          maxImp_obj["Shapes"])
         rt.setINISetting(iniPath_importSettings, "Geometry",
                          "TextureCoords", maxImp_obj["TextureCoords"])
         rt.setINISetting(iniPath_importSettings, "Geometry",
                          "SmoothingGroups", maxImp_obj["SmoothingGroups"])
         rt.setINISetting(iniPath_importSettings, "Geometry", "NormalsType",
                          maxImp_obj["NormalsType"])
         rt.setINISetting(iniPath_importSettings, "Geometry", "SmoothAngle",
                          maxImp_obj["SmoothAngle"])
         rt.setINISetting(iniPath_importSettings, "Geometry", "FlipNormals",
                          maxImp_obj["FlipNormals"])
         rt.setINISetting(iniPath_importSettings, "Units/Scale", "Convert",
                          maxImp_obj["Convert"])
         rt.setINISetting(iniPath_importSettings, "Units/Scale",
                          "ConvertFrom", maxImp_obj["ConvertFrom"])
         rt.setINISetting(iniPath_importSettings, "Units/Scale", "ObjScale",
                          maxImp_obj["ObjScale"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "UniqueWireColor", maxImp_obj["UniqueWireColor"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "ImportMaterials", maxImp_obj["ImportMaterials"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "UseMatPrefix", maxImp_obj["UseMatPrefix"])
         rt.setINISetting(iniPath_importSettings, "Material", "DefaultBump",
                          maxImp_obj["DefaultBump"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "ForceBlackAmbient",
                          maxImp_obj["ForceBlackAmbient"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "ImportIntoMatEditor",
                          maxImp_obj["ImportIntoMatEditor"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "ShowMapsInViewport",
                          maxImp_obj["ShowMapsInViewport"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "CopyMapsToProj", maxImp_obj["CopyMapsToProj"])
         rt.setINISetting(iniPath_importSettings, "Material",
                          "OverwriteImages", maxImp_obj["OverwriteImages"])
         rt.importFile(filePath, rt.Name("NoPrompt"), using=rt.ObjImp)
         return True
     else:
         msg = "OBJ Plugin cannot be initialized. Skipping import"
         rt.messageBox(msg, title='Info')
         return False