def TestFit(selFrame, scale_size, move_dy):
    new_objs = mm.append_objects_from_file(remote, hole_filename)
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", scale_size)
    mm.accept_tool(remote)

    (min, max) = mm.get_selected_bounding_box(remote)

    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    dy = -((cur_origin[1] - min[1]) + move_dy * 2 / size_x)
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    translate = mm.subv3(selFrame.origin, cur_origin)
    translate = mm.addv3(translate, mm.mulv3s(selFrame.z, dy))
    mm.set_toolparam(remote, "translation", translate)
    mm.accept_tool(remote)

    mm.select_objects(remote, [obj_list[0], new_objs[0]])
    result = TestIntersection(obj_list[0], new_objs[0])
    mm.select_objects(remote, [new_objs[0]])
    cmd_D = mmapi.StoredCommands()
    cmd_D.AppendSceneCommand_DeleteSelectedObjects()
    remote.runCommand(cmd_D)
    mm.select_objects(remote, [obj_list[0]])
    return not result
def create_ring(selFrame, scale_size):
    new_objs = mm.append_objects_from_file(remote, ring_name)
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", scale_size)
    mm.accept_tool(remote)

    (min, max) = mm.get_selected_bounding_box(remote)

    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    #dy = flag_set_dy*(-((cur_origin[1] - min[1])+move_dy*2/size_x))
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    translate = mm.subv3(selFrame.origin, cur_origin)
    #translate = mm.addv3( translate, mm.mulv3s( selFrame.z, dy ) )
    mm.set_toolparam(remote, "translation", translate)
    mm.accept_tool(remote)

    #mm.begin_tool(remote, "duplicate")
    #mm.accept_tool(remote)

    mm.select_objects(remote, [obj_list[0], new_objs[0]])

    mm.begin_tool(remote, "combine")
    mm.accept_tool(remote)
    return
Exemple #3
0
def create_ring(tar_object, selFrame, scale_size):
    new_objs = mm.append_objects_from_file(remote, ring_name)
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", scale_size)
    mm.accept_tool(remote)

    (min, max) = mm.get_selected_bounding_box(remote)

    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    translate = mm.subv3(selFrame.origin, cur_origin)
    mm.set_toolparam(remote, "translation", translate)
    mm.accept_tool(remote)

    mm.select_objects(remote, [tar_object, new_objs[0]])

    mm.begin_tool(remote, "combine")
    mm.accept_tool(remote)
    return
Exemple #4
0
def drill_holes(tar_object, selFrame, filenames, scale_size, move_dy,
                flag_set_dy):
    new_objs = mm.append_objects_from_file(remote, filenames)
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", scale_size)
    #mm.set_toolparam(remote, "translation", [0,0,0])
    mm.accept_tool(remote)

    (min, max) = mm.get_selected_bounding_box(remote)

    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    dy = flag_set_dy * (-((cur_origin[1] - min[1]) + move_dy * 2 / size_x))
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    translate = mm.subv3(selFrame.origin, cur_origin)
    translate = mm.addv3(translate, mm.mulv3s(selFrame.z, dy))
    mm.set_toolparam(remote, "translation", translate)
    mm.accept_tool(remote)

    #mm.begin_tool(remote, "duplicate")
    #mm.accept_tool(remote)

    mm.select_objects(remote, [tar_object, new_objs[0]])

    mm.begin_tool(remote, "difference")
    mm.accept_tool(remote)
    return
Exemple #5
0
def TestFit(tar_object, selFrame, scale_size, move_dy):
    new_objs = mm.append_objects_from_file(remote, hole_filename)
    mm.select_objects(remote, new_objs)

    mm.begin_tool(remote, "transform")
    mm.set_toolparam(remote, "scale", scale_size)
    #mm.set_toolparam(remote, "translation", [0,0,0])
    mm.accept_tool(remote)

    (min, max) = mm.get_selected_bounding_box(remote)

    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    dy = -((cur_origin[1] - min[1]) + move_dy * 2 / size_x)
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    translate = mm.subv3(selFrame.origin, cur_origin)
    translate = mm.addv3(translate, mm.mulv3s(selFrame.z, dy))
    mm.set_toolparam(remote, "translation", translate)
    mm.accept_tool(remote)

    mm.select_objects(remote, [tar_object, new_objs[0]])
    result = TestIntersection(tar_object, new_objs[0])
    mm.select_objects(remote, [new_objs[0]])
    delete_select_objects()
    mm.select_objects(remote, [tar_object])
    return not result
    mm.set_toolparam(remote, "scale", [1, size, 1])
    #mm.set_toolparam(remote, "translation", [0,0,0])
    mm.accept_tool(remote)

    # get bbox of part, so that we can put origin at bottom of object if desired
    # (we are assuming that in its file, the part is positioned at the origin, on the ground plane)
    (min, max) = mm.get_selected_bounding_box(remote)

    # start transform tool
    mm.begin_tool(remote, "transform")
    cur_origin = mm.get_toolparam(remote, "origin")
    print(cur_origin)
    print(min)
    dy = -(cur_origin[1] - min[1])
    # compute and apply rotation
    rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z),
                                        selFrame.y)
    mm.set_toolparam(remote, "rotation", rotation)

    # translate origin of part to frame origin
    translate = mm.subv3(selFrame.origin, cur_origin)
    # uncomment this line to shift along frame Z, this will place bottom of part on surface (ie at frame origin)
    #translate = mm.addv3( translate, mm.mulv3s( selFrame.z, dy ) )
    mm.set_toolparam(remote, "translation", translate)

    # accept xform
    mm.accept_tool(remote)

    # make a copy of the object, because boolean will delete it and it is useful to be able to see where the part was
    #mm.begin_tool(remote, "duplicate")
    #mm.accept_tool(remote)
new_objs = mm.append_objects_from_file(remote, part_filename);

# select imported part
mm.select_objects(remote, new_objs)

# get bbox of part, so that we can put origin at bottom of object if desired 
# (we are assuming that in its file, the part is positioned at the origin, on the ground plane)
(min,max) = mm.get_selected_bounding_box(remote)

# start transform tool
mm.begin_tool(remote, "transform")
cur_origin = mm.get_toolparam(remote, "origin")
dy = cur_origin[1] - min[1]

# compute and apply rotation
rotation = mm.make_matrix_from_axes(selFrame.x, mm.negv3(selFrame.z), selFrame.y )
mm.set_toolparam(remote, "rotation", rotation )

# translate origin of part to frame origin
translate = mm.subv3( selFrame.origin, cur_origin )
# uncomment this line to shift along frame Z, this will place bottom of part on surface (ie at frame origin)
#translate = mm.addv3( translate, mm.mulv3s( selFrame.z, dy ) )
mm.set_toolparam(remote, "translation", translate )

# accept xform
mm.accept_tool(remote)

# make a copy of the object, because boolean will delete it and it is useful to be able to see where the part was
mm.begin_tool(remote, "duplicate")
mm.accept_tool(remote)