Exemple #1
0
def selectByNames(namesList):
    """add objects to the current selection

    :param namesList: list containing the object names

    """
    for name in namesList:
        msg = ("SelectByName "+name)
        ue4Conn.sendMessage(msg)
Exemple #2
0
def deselectByNames(namesList):
    """remove objects from the current selection
    
    :param namesList: list containing the object names

    """
    for name in namesList:
        msg = ("DeselectByName "+name)
        ue4Conn.sendMessage(msg)
Exemple #3
0
def deselectByNames(namesList):
    """remove objects from the current selection
    
    :param namesList: list containing the object names

    """
    for name in namesList:
        msg = ("DeselectByName " + name)
        ue4Conn.sendMessage(msg)
Exemple #4
0
def selectByNames(namesList):
    """add objects to the current selection

    :param namesList: list containing the object names

    """
    for name in namesList:
        msg = ("SelectByName " + name)
        ue4Conn.sendMessage(msg)
Exemple #5
0
def addActorBatch(assetList):
    """ add an actor to the level for each entry in the assetList
    each value in the List has to be an `ObjectInfo` object.
    """
    msg = 'AddActorBatch'
    for objInfo in assetList:
        line = objectInfoToString(objInfo)
        msg = msg + "\n" + line
    _lg.debug("assembled add batch command: " + msg)
    ue4Conn.sendMessage(msg)
Exemple #6
0
def addActorBatch(assetList):
    """ add an actor to the level for each entry in the assetList
    each value in the List has to be an `ObjectInfo` object.
    """
    msg = 'AddActorBatch'
    for objInfo in assetList:
        line = objectInfoToString(objInfo)
        msg = msg +"\n" + line
    _lg.debug("assembled add batch command: "+msg)
    ue4Conn.sendMessage(msg)
Exemple #7
0
def parentChildTo(childName, parentName):
    """ set the parent of childName to be parentName

    if parentName is an empty string or None, will parent to the world

    """
    msg = ("ParentChildTo " + childName)
    if (parentName is not None) and (parentName != ''):
        msg = msg + " " + parentName

    ue4Conn.sendMessage(msg)
Exemple #8
0
def parentChildTo(childName, parentName):
    """ set the parent of childName to be parentName

    if parentName is an empty string or None, will parent to the world

    """
    msg = ("ParentChildTo "+childName)
    if (parentName is not None) and (parentName !=''):
        msg = msg + " " + parentName
    
    ue4Conn.sendMessage(msg)
Exemple #9
0
def transformObject(objName, t=None, r=None, s=None):
    """transform an object with absolute transformations.

    :param objName: name of the object to modify
    :param t: translation float tuple or None if not to change
    :param r: rotation float tuple or None if not to change
    :param s: 3d scale float tuple or None if not to change
    
    """
    T = "" if t is None else ("T=(%f %f %f)" % (t[0], t[1], t[2]))
    R = "" if r is None else ("R=(%f %f %f)" % (r[0], r[1], r[2]))
    S = "" if s is None else ("S=(%f %f %f)" % (s[0], s[1], s[2]))
    msg = ("TransformObject "+objName+" "+T+" "+R+" "+S)
    ue4Conn.sendMessage(msg)
Exemple #10
0
def transformObject(objName, t=None, r=None, s=None):
    """transform an object with absolute transformations.

    :param objName: name of the object to modify
    :param t: translation float tuple or None if not to change
    :param r: rotation float tuple or None if not to change
    :param s: 3d scale float tuple or None if not to change
    
    """
    T = "" if t is None else ("T=(%f %f %f)" % (t[0], t[1], t[2]))
    R = "" if r is None else ("R=(%f %f %f)" % (r[0], r[1], r[2]))
    S = "" if s is None else ("S=(%f %f %f)" % (s[0], s[1], s[2]))
    msg = ("TransformObject " + objName + " " + T + " " + R + " " + S)
    ue4Conn.sendMessage(msg)
Exemple #11
0
def importAssetsBatch(relFilePathList):
    """
    import all the asset files in the FilePathList
    the files paths have to be relative to the current
    project's ContentRoot.

    This function will create a matching Destination path for each File path.
        
    """
    if len(relFilePathList) < 1:
        return

    pipe = m2u.core.getPipeline()

    msg = ('ImportAssetsBatch')
    contentRoot = pipe.getProjectExportDir()
    for path in relFilePathList:
        if not path.startswith("/") and len(path) > 0:
            path = "/" + path

        filepath = contentRoot + path
        #rpath,ext = os.path.splitext(path)
        directory = os.path.dirname(path)
        # the import destination has to be without the asset-name
        # it will be auto-generated from the file-name by UE4

        assP = "/Game" + directory.replace("\\", "/")
        assP = assP.replace("//", "/")
        if assP.endswith("/"):
            assP = assP[:-1]

        msg = msg + ' "' + assP + '" "' + filepath + '"'
    _lg.debug("assembled import batch command: \n" + msg)
    result = ue4Conn.sendMessage(msg)
Exemple #12
0
def renameObject(name, newName):
    """try to assign a new name to an object.

    :param name: current name of the object
    :param newName: desired name for the object

    :return: tuple (bool,string) True if no problem occured, False otherwise
    if False, the string will be the name the Editor assigned or None if no
    renaming took place.

    You can use :func:`getFreeName` to find a name that is unused in the
    Editor prior to actually renaming the object.
    """
    msg = ("RenameObject %s %s" % (name, newName))
    result = ue4Conn.sendMessage(msg)
    if result =="1":
        _lg.error(("No object with name '%s' exists" % name))
        # TODO: this maybe should not print an error, maybe a warning or only debug?
        return (False, None)
    if result == newName:
        return (True, None)
    else:
        # the object was (probably) renamed! but the editor changed the name...
        _lg.warn("Rename returned a different name than desired "
               "('%s' instead of '%s')." % (result, newName))
        return (False, result)
Exemple #13
0
def renameObject(name, newName):
    """try to assign a new name to an object.

    :param name: current name of the object
    :param newName: desired name for the object

    :return: tuple (bool,string) True if no problem occured, False otherwise
    if False, the string will be the name the Editor assigned or None if no
    renaming took place.

    You can use :func:`getFreeName` to find a name that is unused in the
    Editor prior to actually renaming the object.
    """
    msg = ("RenameObject %s %s" % (name, newName))
    result = ue4Conn.sendMessage(msg)
    if result == "1":
        _lg.error(("No object with name '%s' exists" % name))
        # TODO: this maybe should not print an error, maybe a warning or only debug?
        return (False, None)
    if result == newName:
        return (True, None)
    else:
        # the object was (probably) renamed! but the editor changed the name...
        _lg.warn("Rename returned a different name than desired "
                 "('%s' instead of '%s')." % (result, newName))
        return (False, result)
Exemple #14
0
def importAssetsBatch(relFilePathList):
    """
    import all the asset files in the FilePathList
    the files paths have to be relative to the current
    project's ContentRoot.

    This function will create a matching Destination path for each File path.
        
    """
    if len(relFilePathList) < 1:
        return
    
    pipe = m2u.core.getPipeline()
    
    msg = ('ImportAssetsBatch')
    contentRoot = pipe.getProjectExportDir()
    for path in relFilePathList:
        if not path.startswith("/") and len(path)>0:
            path = "/"+path
            
        filepath = contentRoot+path
        #rpath,ext = os.path.splitext(path)
        directory = os.path.dirname(path)
        # the import destination has to be without the asset-name
        # it will be auto-generated from the file-name by UE4
        
        assP = "/Game"+directory.replace("\\","/")
        assP = assP.replace("//","/")
        if assP.endswith("/"):
            assP=assP[:-1]
        
        msg = msg + ' "'+assP+'" "'+filepath+'"'
    _lg.debug("assembled import batch command: \n"+msg)
    result = ue4Conn.sendMessage(msg)
Exemple #15
0
def transformCamera(x, y, z, rx, ry, rz, CamIdentifier="All"):
    """Set the Camera in UEd

    :param x,y,z: position for the camera
    :param rx,ry,rz: rotation for the camera
    :param CamIdentifier: string that explains which viewports to set

    By default, all Viewport Cameras will be set to the provided position and
    rotation.

    """
    #TODO: CamIdentifier is not yet used in m2uPlugin, possible values should be:
    #All, AllPersp, AllTop, AllFront, AllSide, or an Index specifying a specific
    #viewport. Or a name for a camera?
    msg = ("TransformCamera %f %f %f %f %f %f %s" % \
           (x,y,z,rx,ry,rz,CamIdentifier))
    ue4Conn.sendMessage(msg)
Exemple #16
0
def transformCamera( x,y,z, rx,ry,rz, CamIdentifier="All"):
    """Set the Camera in UEd

    :param x,y,z: position for the camera
    :param rx,ry,rz: rotation for the camera
    :param CamIdentifier: string that explains which viewports to set

    By default, all Viewport Cameras will be set to the provided position and
    rotation.

    """
    #TODO: CamIdentifier is not yet used in m2uPlugin, possible values should be:
    #All, AllPersp, AllTop, AllFront, AllSide, or an Index specifying a specific
    #viewport. Or a name for a camera?
    msg = ("TransformCamera %f %f %f %f %f %f %s" % \
           (x,y,z,rx,ry,rz,CamIdentifier))
    ue4Conn.sendMessage(msg)
Exemple #17
0
def getFreeName(name, maxIters=5000):
    """ check if the name is in use, if it is, return the next
    unused name by increasing (or adding) the number-suffix

    :param name: the basic name, to check
    :param maxIters: the maximum number of name-checks to perform
    (maxIters currently not used in UE4)
    
    :return: string, name that is free
    
    """
    msg = ("GetFreeName "+name)
    result = ue4Conn.sendMessage(msg)
    return result;
Exemple #18
0
def getFreeName(name, maxIters=5000):
    """ check if the name is in use, if it is, return the next
    unused name by increasing (or adding) the number-suffix

    :param name: the basic name, to check
    :param maxIters: the maximum number of name-checks to perform
    (maxIters currently not used in UE4)
    
    :return: string, name that is free
    
    """
    msg = ("GetFreeName " + name)
    result = ue4Conn.sendMessage(msg)
    return result
Exemple #19
0
def duplicateObject(name, dupName, t=None, r=None, s=None):
    """duplicate an object with optional transformations

    :param name: name of the object to modify
    :param dupName: desired name for the duplicate
    :param t: translation float tuple or None if not to change
    :param r: rotation float tuple or None if not to change
    :param s: 3d scale float tuple or None if not to change

    :return: tuple (int,string) the int will be
        - 0 if no problem occured
        - 1 if the original object could not be found
        - 2 if the name for the duplicate is already taken
        - 3 if the name was changed by the editor
        - 4 error, reason unknown
    Return values 2 and 3 are mutually exclusive by implementation.
    If 3 is returned, the string will be the name the Editor assigned
    and None otherwise.

    If the return value is 1 or 2, the calling function should change
    the name(s) and try again.
    If the return value is (3,string) the calling function must assign
    the returned name to the original object in the Program or find a new
    fitting name and assign it to the duplicated object using the
    :func:`renameObject` function with the returned string as name.

    .. seealso:: :func:`renameObject` :func:`getFreeName`
    
    """
    T = "" if t is None else ("T=(%f %f %f)" % (t[0], t[1], t[2]))
    R = "" if r is None else ("R=(%f %f %f)" % (r[0], r[1], r[2]))
    S = "" if s is None else ("S=(%f %f %f)" % (s[0], s[1], s[2]))
    msg = ("DuplicateObject " + name + " " + dupName + " " + T + " " + R +
           " " + S)
    result = ue4Conn.sendMessage(msg)
    vals = result.split()
    rval = int(vals[0])
    rname = None
    if len(vals) > 1:
        rname = vals[1]

    if rval == 1:
        _lg.error("Duplication failed, original object could not be found.")
    elif rval == 3:
        _lg.warn("Editor returned a different name than desired "
                 "('%s' instead of '%s')." % (rname, dupName))
    return (rval, rname)
Exemple #20
0
def duplicateObject(name, dupName, t=None, r=None, s=None):
    """duplicate an object with optional transformations

    :param name: name of the object to modify
    :param dupName: desired name for the duplicate
    :param t: translation float tuple or None if not to change
    :param r: rotation float tuple or None if not to change
    :param s: 3d scale float tuple or None if not to change

    :return: tuple (int,string) the int will be
        - 0 if no problem occured
        - 1 if the original object could not be found
        - 2 if the name for the duplicate is already taken
        - 3 if the name was changed by the editor
        - 4 error, reason unknown
    Return values 2 and 3 are mutually exclusive by implementation.
    If 3 is returned, the string will be the name the Editor assigned
    and None otherwise.

    If the return value is 1 or 2, the calling function should change
    the name(s) and try again.
    If the return value is (3,string) the calling function must assign
    the returned name to the original object in the Program or find a new
    fitting name and assign it to the duplicated object using the
    :func:`renameObject` function with the returned string as name.

    .. seealso:: :func:`renameObject` :func:`getFreeName`
    
    """
    T = "" if t is None else ("T=(%f %f %f)" % (t[0], t[1], t[2]))
    R = "" if r is None else ("R=(%f %f %f)" % (r[0], r[1], r[2]))
    S = "" if s is None else ("S=(%f %f %f)" % (s[0], s[1], s[2]))
    msg = ("DuplicateObject "+name+" "+dupName+" "+T+" "+R+" "+S)
    result = ue4Conn.sendMessage(msg)
    vals = result.split()
    rval = int(vals[0])
    rname = None
    if len(vals)>1:
        rname = vals[1]
        
    if rval == 1:
        _lg.error("Duplication failed, original object could not be found.")
    elif rval == 3:
        _lg.warn("Editor returned a different name than desired "
               "('%s' instead of '%s')." % (rname, dupName))
    return (rval, rname)
Exemple #21
0
def fetchSelectedObjects():
    """ fast-fetch all selected actors by exporting them into an FBX-File and
    importing that file into the Program.
    Only one file containing all Objects is created.
    This should not be used for creating reusable assets!

    """
    ed = m2u.core.getEditor()
    prog = m2u.core.getProgram()
    pipe = m2u.core.getPipeline()

    path = pipe.getTempFolder()
    path = path + "\m2uTempExport.fbx"

    msg = 'FetchSelected "' + path + '"'
    result = ue4Conn.sendMessage(msg)
    prog.importFile(path)
Exemple #22
0
def fetchSelectedObjects():
    """ fast-fetch all selected actors by exporting them into an FBX-File and
    importing that file into the Program.
    Only one file containing all Objects is created.
    This should not be used for creating reusable assets!

    """
    ed = m2u.core.getEditor()
    prog = m2u.core.getProgram()
    pipe = m2u.core.getPipeline()

    path = pipe.getTempFolder()
    path = path + "\m2uTempExport.fbx"

    msg = ("FetchSelected \"" + path + "\"")
    result = ue4Conn.sendMessage(msg)
    prog.importFile(path)
Exemple #23
0
def createLayer(layerName):
    msg = ("CreateLayer " + layerName)
    return ue4Conn.sendMessage(msg)
Exemple #24
0
def deleteObject(name):
    """ try to delete the object, no return code
    """
    msg = ("DeleteObject " + name)
    ue4Conn.sendMessage(msg)
Exemple #25
0
def hideSelected():
    """hide currently selected objects
    """
    msg = "HideSelected"
    ue4Conn.sendMessage(msg)
Exemple #26
0
def deselectAll():
    """clear the current selection
    """
    ue4Conn.sendMessage("DeselectAll")
Exemple #27
0
def hideByNames(namesList):
    """hide all objects in the namesList
    """
    for name in namesList:
        msg = "HideByName "+name
        ue4Conn.sendMessage(msg)
Exemple #28
0
def deleteSelected():
    msg = ("DeleteSelected")
    ue4Conn.sendMessage(msg)
Exemple #29
0
def deleteObject(name):
    """ try to delete the object, no return code
    """
    msg = ("DeleteObject "+name)
    ue4Conn.sendMessage(msg)
Exemple #30
0
def unhideSelected():
    """show currently selected objects
    """
    msg = "UnhideSelected"
    ue4Conn.sendMessage(msg)
Exemple #31
0
def isolateSelected():
    """hide all but the currently selected objects
    """
    msg = "IsolateSelected"
    ue4Conn.sendMessage(msg)
Exemple #32
0
def createLayer(layerName):
    msg = ("CreateLayer "+layerName)
    return ue4Conn.sendMessage(msg)
Exemple #33
0
def removeObjectFromLayer(objName, layerName):
    msg = ("RemoveObjectFromLayer "+objName+" "+layerName)
    return ue4Conn.sendMessage(msg)
Exemple #34
0
def unhideAll():
    """show all hidden objects
    """
    msg = "UnhideAll"
    ue4Conn.sendMessage(msg)
Exemple #35
0
def deleteSelected():
    msg = ("DeleteSelected")
    ue4Conn.sendMessage(msg)
Exemple #36
0
def unhideLayer(layerName):
    msg = ("UnhideLayer " + layerName)
    return ue4Conn.sendMessage(msg)
Exemple #37
0
def undo():
    msg = ("Undo")
    ue4Conn.sendMessage(msg)
Exemple #38
0
def redo():
    msg = ("Redo")
    ue4Conn.sendMessage(msg)
Exemple #39
0
def addObjectToLayer(objName, layerName, removeFromOthers=True):
    msg = ("AddObjectToLayer "+objName+" "+layerName+" "+removeFromOthers)
    return ue4Conn.sendMessage(msg)
Exemple #40
0
def unhideByNames(namesList):
    """show all objects in the namesList
    """
    for name in namesList:
        msg = "UnhideByName "+name
        ue4Conn.sendMessage(msg)
Exemple #41
0
def removeObjectFromAllLayers(objName):
    msg = ("RemoveObjectFromAllLayers "+objName)
    return ue4Conn.sendMessage(msg)
Exemple #42
0
def addObjectToLayer(objName, layerName, removeFromOthers=True):
    msg = ("AddObjectToLayer " + objName + " " + layerName + " " +
           removeFromOthers)
    return ue4Conn.sendMessage(msg)
Exemple #43
0
def unhideLayer(layerName):
    msg = ("UnhideLayer "+layerName)
    return ue4Conn.sendMessage(msg)
Exemple #44
0
def deselectAll():
    """clear the current selection
    """
    ue4Conn.sendMessage("DeselectAll")
Exemple #45
0
def removeObjectFromLayer(objName, layerName):
    msg = ("RemoveObjectFromLayer " + objName + " " + layerName)
    return ue4Conn.sendMessage(msg)
Exemple #46
0
def redo():
    msg = ("Redo")
    ue4Conn.sendMessage(msg)
Exemple #47
0
def removeObjectFromAllLayers(objName):
    msg = ("RemoveObjectFromAllLayers " + objName)
    return ue4Conn.sendMessage(msg)
Exemple #48
0
def undo():
    msg = ("Undo")
    ue4Conn.sendMessage(msg)