Exemple #1
0
def find_object_by_name(remote, obj_name):
    """Find the ID of the scene object with the given string name. Returns a 2-tuple (boolFound, object_id)"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_FindObjectByName(obj_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetSceneCommandResult_FindObjectByName(cmd_key, result_val)
    return (bFound, result_val.i)
Exemple #2
0
def find_object_by_name(remote, obj_name):
    """Find the ID of the scene object with the given string name. Returns a 2-tuple (boolFound, object_id)"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_FindObjectByName(obj_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetSceneCommandResult_FindObjectByName(cmd_key, result_val)
    return (bFound, result_val.i)
Exemple #3
0
def get_group(remote, objectid, triangleid):
    """returns group id for triangle"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendSceneCommand_GetTriangleGroup(objectid, triangleid)
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_GetTriangleGroup(key1, result_val)
    return result_val.i
Exemple #4
0
def allocate_group(remote, objectid):
    """allocates a new group id"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendSceneCommand_AllocateNewGroupID(objectid)
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_AllocateNewGroupID(key1, result_val)
    return result_val.i
Exemple #5
0
def append_vertex(remote, objectid, position, normal=(0,1,0), color=(1,1,1) ):
    """Appends a vertex to mesh and returns new VertexID"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendSceneCommand_AppendVertex(objectid, to_vec3f(position), to_vec3f(normal), to_vec3f(color) )
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_AppendVertex(key1, result_val)
    return result_val.i
Exemple #6
0
def create_mesh(remote):
    """force MM to compactify mesh object, so that vertex/triangle ids are contiguous"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendSceneCommand_CreateMesh()
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_CreateMesh(key1, result_val)
    return result_val.i
Exemple #7
0
def get_triangle_count(remote, objectid):
    """Returns number of triangles for object"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendSceneCommand_GetTriangleCount(objectid)
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_GetTriangleCount(key1, result_val)
    return result_val.i
Exemple #8
0
def find_object_by_name(remote, obj_name):
    """returns tuple(boolFound, object_id)"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_FindObjectByName(obj_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetSceneCommandResult_FindObjectByName(cmd_key, result_val)
    return (bFound, result_val.i)
Exemple #9
0
def list_number_of_holes(remote):
    """Returns a list of object IDs for the current set of selected scene objects"""
    cmd1 = mmapi.StoredCommands()
    key1 = cmd1.AppendQueryCommand_ListNumberOfHoles()
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetQueryResult_ListNumberOfHoles(key1, result_val)
    return result_val.i
Exemple #10
0
def find_object_by_name(remote, obj_name):
    """returns tuple(boolFound, object_id)"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_FindObjectByName(obj_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetSceneCommandResult_FindObjectByName(cmd_key, result_val)
    return (bFound, result_val.i)
Exemple #11
0
def append_triangle(remote, objectid, newtri, newgroup = 0):
    """Appends a triangle to mesh and returns new TriangleID"""
    cmd1 = mmapi.StoredCommands()
    t = to_vec3i(newtri)
    key1 = cmd1.AppendSceneCommand_AppendTriangle(objectid, to_vec3i(newtri), newgroup )
    remote.runCommand(cmd1)
    result_val = mmapi.any_result()
    cmd1.GetSceneCommandResult_AppendTriangle(key1, result_val)
    return result_val.i
Exemple #12
0
def get_toolparam(remote, param_name):
    """Returns the current value of the given Tool parameter, or empty list if the parameter is not found."""
    cmd = mmapi.StoredCommands()
    key = cmd.AppendGetToolParameterCommand(param_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetToolParameterCommandResult(key, result_val)
    if bFound:
        if result_val.type == 0:
            return result_val.f
        elif result_val.type == 1:
            return result_val.i
        elif result_val.type == 2:
            return result_val.b
        elif result_val.type == 3:
            return (result_val.x, result_val.y, result_val.z)
        elif result_val.type == 4:
            return result_val.m
        else:
            return ()
    else:
        return ()
Exemple #13
0
def get_toolparam(remote, param_name):
    """Returns the current value of the given Tool parameter, or empty list if the parameter is not found."""
    cmd = mmapi.StoredCommands()
    key = cmd.AppendGetToolParameterCommand(param_name)
    remote.runCommand(cmd)
    result_val = mmapi.any_result()
    bFound = cmd.GetToolParameterCommandResult(key, result_val)
    if bFound:
        if result_val.type == 0:
            return result_val.f
        elif result_val.type == 1:
            return result_val.i
        elif result_val.type == 2:
            return result_val.b
        elif result_val.type == 3:
            return (result_val.x, result_val.y, result_val.z)
        elif result_val.type == 4:
            return result_val.m
        else:
            return ()
    else:
        return ()
Exemple #14
0
cmd = mmapi.StoredCommands()
cmd.AppendSceneCommand_DeleteSelectedObjects()
remote.runCommand(cmd)

# read the open file
cmd = mmapi.StoredCommands()
key = cmd.AppendSceneCommand_AppendMeshFile(pathIn)
remote.runCommand(cmd)

###########################################################################
# Modify partition
cmd = mmapi.StoredCommands()
cmd.AppendBeginToolCommand("units")
key = cmd.AppendGetToolParameterCommand("worldX")
remote.runCommand(cmd)
result_val = mmapi.any_result()
bFound = cmd.GetToolParameterCommandResult(key, result_val)

if bFound:
    if result_val.type == 0:
        x = result_val.f
    elif result_val.type == 1:
        x = result_val.i
    elif result_val.type == 2:
        x = result_val.b
    elif result_val.type == 3:
        x = (result_val.x, result_val.y, result_val.z)
    elif result_val.type == 4:
        x = result_val.m
key = cmd.AppendGetToolParameterCommand("worldY")
remote.runCommand(cmd)
v2 = mesh.appendVertex( (15,0,0), n, (0,1,0) )
v3 = mesh.appendVertex( (15,0,15), n, (0,0,1) )
t = mesh.appendTriangle( (v1,v3,v2) )
mesh.write(TEST_FILE_PATH)

# create new scene object from this file
cmd1 = mmapi.StoredCommands()
create_key = cmd1.AppendSceneCommand_AppendPackedMeshFile(TEST_FILE_PATH);
remote.runCommand(cmd1)

# register a new livemesh object based on this file and read back livemesh portname
cmd2 = mmapi.StoredCommands()
create_key = cmd2.AppendSceneCommand_CreateLiveMeshObject(TEST_FILE_PATH);
remote.runCommand(cmd2)
port_name_vec = mmapi.vectorub()
obj_id = mmapi.any_result()
cmd2.GetSceneCommandResult_CreateLiveMeshObject(create_key, port_name_vec, obj_id)
port_name = mm.vectorub_to_string(port_name_vec)
portid = obj_id.i

# animate this mesh
for i in range(0,2500):
    mesh.vertices[0] = (0, 0+i*0.1, 0)

    cmd_lock = mmapi.StoredCommands()
    cmd_lock.AppendSceneCommand_RequestLiveMeshLock(port_name);
    remote.runCommand(cmd_lock);

    mesh.write(TEST_FILE_PATH)

    cmd_update = mmapi.StoredCommands()