def select_objects(remote, objects_list): select_objects = mmapi.vectori(); for object in objects_list: select_objects.push_back(object); cmd2 = mmapi.StoredCommands() cmd2.AppendSceneCommand_SelectObjects(select_objects) remote.runCommand(cmd2)
def select_objects(remote, objects_list): select_objects = mmapi.vectori() for object in objects_list: select_objects.push_back(object) cmd2 = mmapi.StoredCommands() cmd2.AppendSceneCommand_SelectObjects(select_objects) remote.runCommand(cmd2)
def list_objects(remote): """returns list of objects in scene""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSceneCommand_ListObjects() remote.runCommand(cmd1) objects = mmapi.vectori() cmd1.GetSceneCommandResult_ListObjects(key1, objects) return vectori_to_list(objects)
def append_objects_from_file(remote, filename): """returns list of new objects""" cmd = mmapi.StoredCommands() key = cmd.AppendSceneCommand_AppendMeshFile(filename) remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(key, new_objs_vec) return vectori_to_list(new_objs_vec)
def toolquery_new_groups(remote): """Get a list of new groups created by last tool (NOTE: many Tools do not support this yet!)""" cmd = mmapi.StoredCommands() key = cmd.AppendToolQuery_NewGroups() remote.runCommand(cmd) new_groups = mmapi.vectori() bOK = cmd.GetToolQueryResult_NewGroups(key, new_groups) return vectori_to_list(new_groups)
def list_selected_triangles(remote): """Returns a list of currently-selected triangles (requires an active selection)""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedTriangles() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedTriangles(key1, groups1); return vectori_to_list(groups1);
def toolquery_new_groups(remote): """get list of new groups created by last tool""" cmd = mmapi.StoredCommands() key = cmd.AppendToolQuery_NewGroups() remote.runCommand(cmd) new_groups = mmapi.vectori() bOK = cmd.GetToolQueryResult_NewGroups(key, new_groups) return vectori_to_list(new_groups)
def list_selected_groups(remote): """returns list of selected facegroup IDs""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedFaceGroups() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedFaceGroups(key1, groups1); return vectori_to_list(groups1);
def list_selected_groups(remote): """returns list of selected facegroup IDs""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedFaceGroups() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedFaceGroups(key1, groups1) return vectori_to_list(groups1)
def append_objects_from_file(remote, filename): """Read objects from a mesh file, append them to the scene, and return a list of new object IDs""" cmd = mmapi.StoredCommands() key = cmd.AppendSceneCommand_AppendMeshFile(filename); remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(key, new_objs_vec) return vectori_to_list(new_objs_vec)
def append_objects_from_file(remote, filename): """returns list of new objects""" cmd = mmapi.StoredCommands() key = cmd.AppendSceneCommand_AppendMeshFile(filename); remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(key, new_objs_vec) return vectori_to_list(new_objs_vec)
def list_selected_groups(remote): """Returns a list of unique facegroup IDs for the current face selection (requires an active selection)""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedFaceGroups() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedFaceGroups(key1, groups1) return vectori_to_list(groups1)
def select_objects(remote, objects_list): """Set the current objects selection to be the set of scene objects corresponding to the IDs in objects_list""" select_objects = mmapi.vectori() for object in objects_list: select_objects.push_back(object) cmd2 = mmapi.StoredCommands() cmd2.AppendSceneCommand_SelectObjects(select_objects) remote.runCommand(cmd2)
def append_objects_from_file(remote, filename): """Read objects from a mesh file, append them to the scene, and return a list of new object IDs""" cmd = mmapi.StoredCommands() key = cmd.AppendSceneCommand_AppendMeshFile(filename) remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(key, new_objs_vec) return vectori_to_list(new_objs_vec)
def list_selected_objects(remote): """Returns a list of object IDs for the current set of selected scene objects""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSceneCommand_ListSelectedObjects() remote.runCommand(cmd1) objects = mmapi.vectori() cmd1.GetSceneCommandResult_ListObjects(key1, objects) return vectori_to_list(objects)
def list_selected_triangles(remote): """Returns a list of currently-selected triangles (requires an active selection)""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedTriangles() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedTriangles(key1, groups1) return vectori_to_list(groups1)
def create_pivot(remote, frame): """create a pivot at a given mmFrame (not frame3f)""" cmd = mmapi.StoredCommands() cmd_key = cmd.AppendSceneCommand_CreatePivot(frame.get_frame3f()) remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(cmd_key, new_objs_vec) return new_objs_vec[0]
def create_pivot(remote, frame): """create a pivot at a given mmFrame (not frame3f)""" cmd = mmapi.StoredCommands() cmd_key = cmd.AppendSceneCommand_CreatePivot( frame.get_frame3f() ) remote.runCommand(cmd) new_objs_vec = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(cmd_key, new_objs_vec) return new_objs_vec[0]
def list_selected_groups(remote): """Returns a list of unique facegroup IDs for the current face selection (requires an active selection)""" cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSelectCommand_ListSelectedFaceGroups() remote.runCommand(cmd1) groups1 = mmapi.vectori() cmd1.GetSelectCommandResult_ListSelectedFaceGroups(key1, groups1); return vectori_to_list(groups1);
def select_objects(remote, objects_list): """Set the current objects selection to be the set of scene objects corresponding to the IDs in objects_list""" select_objects = mmapi.vectori(); for object in objects_list: select_objects.push_back(object); cmd2 = mmapi.StoredCommands() cmd2.AppendSceneCommand_SelectObjects(select_objects) remote.runCommand(cmd2)
def select_triangles(remote, triangles_list, mode=0): """Select the listed triangles""" cmd = mmapi.StoredCommands() vtris = mmapi.vectori() for t in triangles_list: vtris.push_back(t) cmd2 = mmapi.StoredCommands() cmd2.AppendSelectCommand_ByTriangleID(vtris, mode) remote.runCommand(cmd2)
def select_triangles(remote, triangles_list, mode = 0): """Select the listed triangles""" cmd = mmapi.StoredCommands() vtris = mmapi.vectori(); for t in triangles_list: vtris.push_back(t); cmd2 = mmapi.StoredCommands() cmd2.AppendSelectCommand_ByTriangleID(vtris, mode) remote.runCommand(cmd2)
def select_facegroups(remote, groups_list): """select facegroups""" cmd = mmapi.StoredCommands() vgroups = mmapi.vectori() for group in groups_list: vgroups.push_back(group) cmd2 = mmapi.StoredCommands() cmd2.AppendSelectCommand_ByFaceGroups(vgroups) remote.runCommand(cmd2)
def select_facegroups(remote, groups_list): """Select the faces which have a facegroup ID in groups_list""" cmd = mmapi.StoredCommands() vgroups = mmapi.vectori(); for group in groups_list: vgroups.push_back(group); cmd2 = mmapi.StoredCommands() cmd2.AppendSelectCommand_ByFaceGroups(vgroups) remote.runCommand(cmd2)
def append_mesh_file(remote, dyr, nym, typ): cmd = mmapi.StoredCommands() input_file_name = dyr + nym + '.' + typ key = cmd.AppendSceneCommand_AppendMeshFile(input_file_name) remote.runCommand(cmd) objs_veci = mmapi.vectori() cmd.GetSceneCommandResult_AppendMeshFile(key, objs_veci) objs = vectori_to_list(objs_veci) print({ 'result_key_from_append_mesh': key, 'asset_dir': dyr, 'input_mesh_file_name': input_file_name, 'input_mesh_file_type': typ, 'first_obj': objs[0] if objs else None, 'last_obj': objs[-1] if objs else None, 'number_of_objs': len(objs) })
pathIn = txtfiles[0] pathTemp = pathIn.split('.') # out file pathOut = pathTemp[0] + '_support.' + pathTemp[1] # initialize connection remote = mmRemote() remote.connect() # get all the objects cmd1 = mmapi.StoredCommands() key1 = cmd1.AppendSceneCommand_ListObjects() remote.runCommand(cmd1) objects = mmapi.vectori() cmd1.GetSceneCommandResult_ListObjects(key1, objects) # select all the objects select_objects = mmapi.vectori() for object in objects: select_objects.push_back(object) cmd2 = mmapi.StoredCommands() cmd2.AppendSceneCommand_SelectObjects(select_objects) remote.runCommand(cmd2) # delete all cmd = mmapi.StoredCommands() cmd.AppendSceneCommand_DeleteSelectedObjects() remote.runCommand(cmd)