def align_min_z(selected_items): item_positions = [general.get_position(item) for item in selected_items] min_z = min([item[2] for item in item_positions]) for idx, item in enumerate(selected_items): general.set_position( item, item_positions[idx][0], item_positions[idx][1], min_z )
def align_x(selected_items): item_positions = [general.get_position(item) for item in selected_items] max_x = max([item[0] for item in item_positions]) for idx, item in enumerate(selected_items): general.set_position( item, max_x, item_positions[idx][1], item_positions[idx][2] )
def paste_xforms(): store = UserValues() selected = general.get_names_of_selected_objects()[0] if selected is None: general.message_box_ok("Please Select an object") xforms = store.get("xforms") general.set_position(selected, xforms['pos'][0], xforms['pos'][1], xforms['pos'][2]) general.set_rotation(selected, xforms['rot'][0], xforms['rot'][1], xforms['rot'][2]) general.set_scale(selected, xforms['scale'][0], xforms['scale'][1], xforms['scale'][2])
def select_copy_paste(letter="", index=0): """ select and copy our polygon item then return to original item and selCopyPast :param letter: letter to select :param index: position of the current letter :return: None """ general.clear_selection() general.select_object(letter) general.set_position(letter, 0, -TEXT_WIDTH * index, 0)
def add_to_scene(obj): print("Adding: " + obj["name"]) store = UserValues(init_funcs=[init_screenshot_values]) store.set("current_icon_object", obj) ico_obj = "icon_object_shot" ico_obj_2 = "icon_object_shot_2" # update our ico_obj based on the settings from the collected icon_object general.set_position(ico_obj, obj["pos"][0], obj["pos"][1], obj["pos"][2]) general.set_scale(ico_obj, obj["scale"][0], obj["scale"][1], obj["scale"][2]) general.set_rotation(ico_obj, obj["rot"][0], obj["rot"][1], obj["rot"][2]) general.set_entity_geometry_file(ico_obj, str(obj["brush"])) general.select_object(ico_obj) material.reset_selection() if obj["mtl"] is not None: general.set_custom_material(ico_obj, str(obj["mtl"])) if "tod" in obj.keys(): tod_list = [str("e_TimeOfDay %s" % obj["tod"])] cycleConsolValue("mode_%s" % "e_TimeOfDay", tod_list)
def capture(): scripts_dir = os.path.abspath(os.path.dirname(__file__)) screenshot_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "user", "screenshots")) images = get_all_files(".jpg", screenshot_dir) general.clear_selection() if general.is_helpers_shown(): general.toggle_helpers() # if general.get_viewport_size() == (3840, 2160): # general.set_viewport_size(3840, 2160) if len(sys.argv) == 3: if sys.argv[2] == "--pink": general.set_position("icon_pink_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_green_screen", 0, 0, 0) else: general.set_position("icon_green_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_pink_screen", 0, 0, 0) general.run_console("r_getScreenshot 1") obj = get_icon_object_in_scene() keys = obj.keys() embellishment_string = "" if u"embellishment_48" in keys: embellishment_string += "--embellishment_48 " + obj[ "embellishment_48"] + " " if u"embellishment_200" in keys: embellishment_string += "--embellishment_200 " + obj[ "embellishment_200"] + " " if u"embellishment_2048" in keys: embellishment_string += "--embellishment_2048 " + obj[ "embellishment_2048"] + " " if u"embellishment_under" in keys: embellishment_string += "--embellishment_under" print(embellishment_string) if obj: # the object exists in our db # save it and overwrite the current version then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(obj["name"], overwrite=True), images, embellishments=embellishment_string, ) else: # the objects does not exist in our db # Ask the user what it is and save it and then execute_external_icon_exe the script execute_external_icon_exe(scripts_dir, save(), images, embellishments=embellishment_string)
def capture(): scripts_dir = os.path.abspath(os.path.dirname(__file__)) screenshot_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "user", "screenshots") ) images = get_all_files(".jpg", screenshot_dir) general.clear_selection() if general.is_helpers_shown(): general.toggle_helpers() # if general.get_viewport_size() == (3840, 2160): # general.set_viewport_size(3840, 2160) if len(sys.argv) == 3: if sys.argv[2] == "--pink": general.set_position("icon_pink_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_green_screen", 0, 0, 0) else: general.set_position("icon_green_screen", 992.4509, 1047.51, 47.6817) general.set_position("icon_pink_screen", 0, 0, 0) general.run_console("r_getScreenshot 1") obj = get_icon_object_in_scene() keys = obj.keys() embellishment_string = "" if u"embellishment_48" in keys: embellishment_string += "--embellishment_48 " + obj["embellishment_48"] + " " if u"embellishment_200" in keys: embellishment_string += "--embellishment_200 " + obj["embellishment_200"] + " " if u"embellishment_2048" in keys: embellishment_string += "--embellishment_2048 " + obj["embellishment_2048"] + " " if u"embellishment_under" in keys: embellishment_string += "--embellishment_under" print(embellishment_string) if obj: # the object exists in our db # save it and overwrite the current version then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(obj["name"], overwrite=True), images, embellishments=embellishment_string, ) else: # the objects does not exist in our db # Ask the user what it is and save it and then execute_external_icon_exe the script execute_external_icon_exe( scripts_dir, save(), images, embellishments=embellishment_string )
def align_x(selected_items): item_positions = [general.get_position(item) for item in selected_items] max_x = max([item[0] for item in item_positions]) for idx, item in enumerate(selected_items): general.set_position(item, max_x, item_positions[idx][1], item_positions[idx][2])
def align_min_z(selected_items): item_positions = [general.get_position(item) for item in selected_items] min_z = min([item[2] for item in item_positions]) for idx, item in enumerate(selected_items): general.set_position(item, item_positions[idx][0], item_positions[idx][1], min_z)
obj_scale = general.get_scale(user_selection) # 2. Create rigid body ex and copy model to rigidbodyex # create the object at 0,0,0 PHYS_OBJECT_NAME = general.new_object("Entity", r"RigidBodyEx", PHYS_OBJECT_NAME, 0, 0, 0) # mark it with a special material so you know it's being simulated general.set_custom_material(PHYS_OBJECT_NAME, 'Materials/Special/green_screen.mtl') # set the physobj to be the selected brush object user_selection_brush = str(lodtools.getselected()) general.set_entity_geometry_file(PHYS_OBJECT_NAME, user_selection_brush) # 3. snap physobj to xform of selected object general.set_position(PHYS_OBJECT_NAME, int(obj_pos[0]), int(obj_pos[1]), int(obj_pos[2])) general.set_rotation(PHYS_OBJECT_NAME, int(obj_rot[0]), int(obj_rot[1]), int(obj_rot[2])) general.set_scale(PHYS_OBJECT_NAME, int(obj_scale[0]), int(obj_scale[1]), int(obj_scale[2])) # 5 Hide user selection object general.log("hiding " + user_selection) general.hide_object(user_selection) # 6. simulate physobj # select the physics object general.select_object(PHYS_OBJECT_NAME) # simulate it physics.simulate_selection()