Beispiel #1
0
def main(args):
    # parser args
    parser = argparse.ArgumentParser(
        description="Convert an OBJ file into an Alembic file.")
    parser.add_argument(
        "obj_in",
        type=str,
        metavar="{OBJ file}",
        help="input OBJ file to be converted to an alembic file")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic file name}",
                        help="optional output file name, default is \"a.abc\"")
    ns = vars(parser.parse_args(args[1:]))

    print("Parsing " + ns["obj_in"])
    file_in = open(ns["obj_in"], "r")
    obj_st = OBJ_structure().read(file_in)
    file_in.close()

    obj_st.OBJ_status()

    abc_out = ns["o"]
    if abc_out == None:
        abc_out = "a.out"

    print("Creating " + abc_out)
    archive = alembic.getOArchive(abc_out)
    obj_st.to_alembic(archive)
def main(args):
   # parser args
   parser = argparse.ArgumentParser(description="Overwrite specific properties in objects with corresponding properties in a second file (with a similar structure).")
   parser.add_argument("abc_files", metavar="{Alembic files}", type=str, nargs="+", help="alembic file to merge")
   parser.add_argument("-o", type=str, metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   parser.add_argument("-p", type=str, metavar="{Property to replace}", help="Property to replace. Must be a property of the object. Not in a compound.")
   ns = vars(parser.parse_args(args[1:]))
   
   abc_files = ns["abc_files"]
   if len(abc_files) != 2:
      print("Error: need two files to merge")
      return
   
   if ns["o"] in abc_files:
      print("Error: the output filename must be distinct from all the input files")
      return
   
   ins = ns["abc_files"]
   src_data = alembic.getIArchive(ins[0])
   rep_data = alembic.getIArchive(ins[1])
   out_data = alembic.getOArchive(ns["o"])
   TSs = src_data.getSampleTimes()
   print(str(TSs))
   out_data.createTimeSampling(TSs)
   
   copy_objects(src_data, rep_data, out_data, ns["p"])
def main(args):
   # parser args
   parser = argparse.ArgumentParser(description="Copy an alembic file into a new one by changing it's time sampling.\n\nNote that this program doesn't validate the time sampling. It's possible to create time samplings with negative values.")
   parser.add_argument("abc_in", type=str,   metavar="{Alembic input file}",  help="input alembic file to be copied and retimed")
   parser.add_argument("-o",     type=str,   metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   parser.add_argument("-s",     type=float, metavar="{scaling factor}",      help="scaling factor, default is 1.0",                  default=1.0)
   parser.add_argument("-a",     type=float, metavar="{offset}",              help="offset for the time sampling, default is 0.0",    default=0.0)
   ns = vars(parser.parse_args(args[1:]))
   
   if ns["abc_in"] == ns["o"]:
      print("Error: input and output filenames must be different")
      return
   
   scale  = ns["s"]
   offset = ns["a"]
   
   if scale <= 0.0:
      print("Error: the scale factor cannot be less or equal to zero")
      return
   
   in_data  = alembic.getIArchive(ns["abc_in"])
   out_data = alembic.getOArchive(ns["o"])
   ori_ts = in_data.getSampleTimes()
   new_ts = create_new_TS(ori_ts, scale, offset)
   out_data.createTimeSampling(new_ts)
   copy_objects(in_data, out_data)
   
   print("\n\n")
def main(args):
   global b_verbose
   global obj_filter
   global typ_filter
   global noo_filter
   global not_filter
   
   # parser args
   parser = argparse.ArgumentParser(description="Copy integrally, or partially, an alembic file into a second alembic file")
   parser.add_argument("abc_in", type=str, metavar="{Alembic input file}", help="input alembic file to be copied")
   parser.add_argument("-o", type=str, metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   parser.add_argument("-v", "--verbose", action='store_true', help='show the details of the copy')
   parser.add_argument("-f", "--filter", type=str, metavar="{id filter}", help="only copy objects containing substring {id filter} in their identifier")
   parser.add_argument("-T", "--typefilter", type=str, metavar="{type filter}", help="only copy objects containing substring {type filter} in their type")
   parser.add_argument("-nf", "--NOTfilter", type=str, metavar="{id filter}", help="only copy objects NOT containing substring {id filter} in their identifier")
   parser.add_argument("-nT", "--NOTtypefilter", type=str, metavar="{type filter}", help="only copy objects NOT containing substring {type filter} in their type")
   ns = vars(parser.parse_args(args[1:]))
   
   if ns["abc_in"] == ns["o"]:
      print("Error: input and output filenames must be different")
      return
   
   b_verbose = ns["verbose"]
   obj_filter = ns["filter"]
   typ_filter = ns["typefilter"]
   noo_filter = ns["NOTfilter"]
   not_filter = ns["NOTtypefilter"]
   
   in_data = alembic.getIArchive(ns["abc_in"])
   out_data = alembic.getOArchive(ns["o"])
   out_data.createTimeSampling(in_data.getSampleTimes())
   copy_objects(in_data, out_data)
Beispiel #5
0
def main(args):
    global concat_ts
    global vertex_def
    global final_tss

    # parser args
    parser = argparse.ArgumentParser(
        description="Concatenate multiple alembic files only if their geometries are identical.\n\nCurrently, it only supports Xforms. Issue #16 on GitHub is about adding vertex/normal deformations."
    )
    parser.add_argument("abc_files", metavar="{Alembic file}", type=str, nargs="+", help="alembic file to concatenate")
    parser.add_argument(
        "-o",
        type=str,
        metavar="{Alembic output file}",
        help='optional output file name, default is "a.abc"',
        default="a.abc",
    )
    ns = vars(parser.parse_args(args[1:]))

    abc_files = ns["abc_files"]
    if len(abc_files) < 2:
        print("Error: need at least two files for the concatenation")
        return

    for abc in abc_files:
        if abc == ns["o"]:
            print("Error: the output filename must be distinct from all the input files")
            return

    # read the first file and extract the time sampling, xforms and identifying vertex deforms
    print("\n\nScanning: " + abc_files[0])
    extract_ts_xforms(alembic.getIArchive(abc_files[0]))

    # go through the remaining files and accumulate the data about the time sampling, xforms and identifying more if necessary vertex deforms
    try:
        for abc in abc_files[1:]:
            print("Scanning: " + abc)
            concat_ts_xforms(alembic.getIArchive(abc))
    except Exception as abc_error:
        print("Error: not able to concatenate file " + abc_error)
        return

    # compute the new TSs
    create_concat_ts()

    # create the concatenate archive
    print("\nCreating:  " + ns["o"])
    out_arch = alembic.getOArchive(ns["o"])
    out_arch.createTimeSampling(final_tss)
    firstFile = True

    # going through each file to append their xforms
    for abc in abc_files:
        print("\t>> " + abc)
        create_output(out_arch, alembic.getIArchive(abc), firstFile)
        firstFile = False

    out_arch = None
    print("\n\n")
Beispiel #6
0
def main(args):
   # parser args
   parser = argparse.ArgumentParser(description="Copy integrally an alembic file into a second alembic file")
   parser.add_argument("abc_in", type=str, metavar="{Alembic input file}", help="input alembic file to be copied")
   parser.add_argument("-o", type=str, metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   ns = vars(parser.parse_args(args[1:]))
   
   if ns["abc_in"] == ns["o"]:
      print("Error: input and output filenames must be different")
      return
   
   in_data = alembic.getIArchive(ns["abc_in"])
   out_data = alembic.getOArchive(ns["o"])
   out_data.createTimeSampling(in_data.getSampleTimes())
   copy_objects(in_data, out_data)
Beispiel #7
0
def main(args):
    # parser args
    parser = argparse.ArgumentParser(
        description=
        "Copy an alembic file into a new one by changing it's time sampling.\n\nNote that this program doesn't validate the time sampling. It's possible to create time samplings with negative values."
    )
    parser.add_argument("abc_in",
                        type=str,
                        metavar="{Alembic input file}",
                        help="input alembic file to be copied and retimed")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    parser.add_argument("-s",
                        type=float,
                        metavar="{scaling factor}",
                        help="scaling factor, default is 1.0",
                        default=1.0)
    parser.add_argument("-a",
                        type=float,
                        metavar="{offset}",
                        help="offset for the time sampling, default is 0.0",
                        default=0.0)
    ns = vars(parser.parse_args(args[1:]))

    if ns["abc_in"] == ns["o"]:
        print("Error: input and output filenames must be different")
        return

    scale = ns["s"]
    offset = ns["a"]

    if scale <= 0.0:
        print("Error: the scale factor cannot be less or equal to zero")
        return

    in_data = alembic.getIArchive(ns["abc_in"])
    out_data = alembic.getOArchive(ns["o"])
    ori_ts = in_data.getSampleTimes()
    new_ts = create_new_TS(ori_ts, scale, offset)
    out_data.createTimeSampling(new_ts)
    copy_objects(in_data, out_data)

    print("\n\n")
Beispiel #8
0
def main(args):
    # parser args
    parser = argparse.ArgumentParser(
        description=
        "Overwrite specific properties in objects with corresponding properties in a second file (with a similar structure)."
    )
    parser.add_argument("abc_files",
                        metavar="{Alembic files}",
                        type=str,
                        nargs="+",
                        help="alembic file to merge")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    parser.add_argument(
        "-p",
        type=str,
        metavar="{Property to replace}",
        help=
        "Property to replace. Must be a property of the object. Not in a compound."
    )
    ns = vars(parser.parse_args(args[1:]))

    abc_files = ns["abc_files"]
    if len(abc_files) != 2:
        print("Error: need two files to merge")
        return

    if ns["o"] in abc_files:
        print(
            "Error: the output filename must be distinct from all the input files"
        )
        return

    ins = ns["abc_files"]
    src_data = alembic.getIArchive(ins[0])
    rep_data = alembic.getIArchive(ins[1])
    out_data = alembic.getOArchive(ns["o"])
    TSs = src_data.getSampleTimes()
    print(str(TSs))
    out_data.createTimeSampling(TSs)

    copy_objects(src_data, rep_data, out_data, ns["p"])
Beispiel #9
0
def main(args):
    global str_search
    global str_replace

    # parser args
    parser = argparse.ArgumentParser(
        description=
        "Copy an alembic file into a second alembic file with the option to change to rename objects."
    )
    parser.add_argument("abc_in",
                        type=str,
                        metavar="{Alembic input file}",
                        help="input alembic file to be copied")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    parser.add_argument("-s",
                        type=str,
                        metavar="{search}",
                        help="the substring to search in the object names",
                        required=True)
    parser.add_argument(
        "-r",
        type=str,
        metavar="{replace}",
        help=
        "the substring to replace the search substring with in the object names",
        required=True)
    ns = vars(parser.parse_args(args[1:]))

    if ns["abc_in"] == ns["o"]:
        print("Error: input and output filenames must be different")
        return
    str_search = ns["s"]
    str_replace = ns["r"]

    in_data = alembic.getIArchive(ns["abc_in"])
    out_data = alembic.getOArchive(ns["o"])
    out_data.createTimeSampling(in_data.getSampleTimes())
    copy_objects(in_data, out_data)
Beispiel #10
0
def main(args):
   # parser args
   parser = argparse.ArgumentParser(description="Convert an OBJ file into an Alembic file.")
   parser.add_argument("obj_in", type=str, metavar="{OBJ file}", help="input OBJ file to be converted to an alembic file")
   parser.add_argument("-o", type=str, metavar="{Alembic file name}", help="optional output file name, default is \"a.abc\"")
   ns = vars(parser.parse_args(args[1:]))
   
   
   print("Parsing " + ns["obj_in"])
   file_in = open(ns["obj_in"], "r")
   obj_st = OBJ_structure().read(file_in)
   file_in.close()
   
   obj_st.OBJ_status()
   
   abc_out = ns["o"]
   if abc_out == None:
      abc_out = "a.out"

   print("Creating " + abc_out)
   archive = alembic.getOArchive(abc_out)
   obj_st.to_alembic(archive)
Beispiel #11
0
def main(args):
   global str_search
   global str_replace
   
   # parser args
   parser = argparse.ArgumentParser(description="Copy an alembic file into a second alembic file with the option to change to rename objects.")
   parser.add_argument("abc_in", type=str, metavar="{Alembic input file}", help="input alembic file to be copied")
   parser.add_argument("-o", type=str, metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   parser.add_argument("-s", type=str, metavar="{search}", help="the substring to search in the object names", required=True)
   parser.add_argument("-r", type=str, metavar="{replace}", help="the substring to replace the search substring with in the object names", required=True)
   ns = vars(parser.parse_args(args[1:]))
   
   if ns["abc_in"] == ns["o"]:
      print("Error: input and output filenames must be different")
      return
   str_search  = ns["s"]
   str_replace = ns["r"]
   
   in_data = alembic.getIArchive(ns["abc_in"])
   out_data = alembic.getOArchive(ns["o"])
   out_data.createTimeSampling(in_data.getSampleTimes())
   copy_objects(in_data, out_data)
Beispiel #12
0
def main(args):
   conflict_string = "how to deal with objects with the same name in different files. Option --first-- keeps the first instance found, --last-- keeps the last instance found, and --rename-- renames the object with the file ID (order in which they're specified as parameter) to be unique."
   
   # parser args
   parser = argparse.ArgumentParser(description="Merge multiple alembic files in one file.\n\nNote that to avoid any confusion, the objects' names are altered in the output file by adding the file ID (the number in which the file is specified as a parameter) at the beginning of the name.")
   parser.add_argument("abc_files", metavar="{Alembic files}", type=str, nargs="+", help="alembic file to merge")
   parser.add_argument("-o", type=str, metavar="{Alembic output file}", help="optional output file name, default is \"a.abc\"", default="a.abc")
   parser.add_argument("-c", choices=("first", "last", "rename"), help=conflict_string, default="first")
   ns = vars(parser.parse_args(args[1:]))
   
   abc_files = ns["abc_files"]
   if len(abc_files) < 2:
      print("Error: need at least two files to merge")
      return
   
   for abc in abc_files:
      if abc == ns["o"]:
         print("Error: the output filename must be distinct from all the input files")
         return
   
   # 1. scan the files
   ts_man = ts_manager(ns["c"])
   idx = 0
   for abcf in abc_files:
      ts_man.scan_alembic(alembic.getIArchive(abcf), idx)
      idx = idx + 1
   
   # 2. create output archive and assign the time sampling
   out_data = alembic.getOArchive(ns["o"])
   out_data.createTimeSampling(ts_man.get_time_sampling())
   
   # 3. copy the object in the output file
   idx = 0
   for abcf in abc_files:
      copy_objects(ts_man, alembic.getIArchive(abcf), out_data, idx, ts_man.get_file_indices(idx))
      idx = idx + 1
   print("\n\n")
Beispiel #13
0
def main(args):
    # parser args
    parser = argparse.ArgumentParser(
        description="Copy integrally an alembic file into a second alembic file"
    )
    parser.add_argument("abc_in",
                        type=str,
                        metavar="{Alembic input file}",
                        help="input alembic file to be copied")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    ns = vars(parser.parse_args(args[1:]))

    if ns["abc_in"] == ns["o"]:
        print("Error: input and output filenames must be different")
        return

    in_data = alembic.getIArchive(ns["abc_in"])
    out_data = alembic.getOArchive(ns["o"])
    out_data.createTimeSampling(in_data.getSampleTimes())
    copy_objects(in_data, out_data)
Beispiel #14
0
def main(args):
    global b_verbose
    global obj_filter
    global typ_filter
    global noo_filter
    global not_filter

    # parser args
    parser = argparse.ArgumentParser(
        description=
        "Copy integrally, or partially, an alembic file into a second alembic file"
    )
    parser.add_argument("abc_in",
                        type=str,
                        metavar="{Alembic input file}",
                        help="input alembic file to be copied")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    parser.add_argument("-v",
                        "--verbose",
                        action='store_true',
                        help='show the details of the copy')
    parser.add_argument(
        "-f",
        "--filter",
        type=str,
        metavar="{id filter}",
        help=
        "only copy objects containing substring {id filter} in their identifier"
    )
    parser.add_argument(
        "-T",
        "--typefilter",
        type=str,
        metavar="{type filter}",
        help=
        "only copy objects containing substring {type filter} in their type")
    parser.add_argument(
        "-nf",
        "--NOTfilter",
        type=str,
        metavar="{id filter}",
        help=
        "only copy objects NOT containing substring {id filter} in their identifier"
    )
    parser.add_argument(
        "-nT",
        "--NOTtypefilter",
        type=str,
        metavar="{type filter}",
        help=
        "only copy objects NOT containing substring {type filter} in their type"
    )
    ns = vars(parser.parse_args(args[1:]))

    if ns["abc_in"] == ns["o"]:
        print("Error: input and output filenames must be different")
        return

    b_verbose = ns["verbose"]
    obj_filter = ns["filter"]
    typ_filter = ns["typefilter"]
    noo_filter = ns["NOTfilter"]
    not_filter = ns["NOTtypefilter"]

    in_data = alembic.getIArchive(ns["abc_in"])
    out_data = alembic.getOArchive(ns["o"])
    out_data.createTimeSampling(in_data.getSampleTimes())
    copy_objects(in_data, out_data)
Beispiel #15
0
def main(args):
    global concat_ts
    global vertex_def
    global final_tss

    # parser args
    parser = argparse.ArgumentParser(
        description=
        "Concatenate multiple alembic files only if their geometries are identical.\n\nCurrently, it only supports Xforms. Issue #16 on GitHub is about adding vertex/normal deformations."
    )
    parser.add_argument("abc_files",
                        metavar="{Alembic file}",
                        type=str,
                        nargs="+",
                        help="alembic file to concatenate")
    parser.add_argument("-o",
                        type=str,
                        metavar="{Alembic output file}",
                        help="optional output file name, default is \"a.abc\"",
                        default="a.abc")
    ns = vars(parser.parse_args(args[1:]))

    abc_files = ns["abc_files"]
    if len(abc_files) < 2:
        print("Error: need at least two files for the concatenation")
        return

    for abc in abc_files:
        if abc == ns["o"]:
            print(
                "Error: the output filename must be distinct from all the input files"
            )
            return

    #read the first file and extract the time sampling, xforms and identifying vertex deforms
    print("\n\nScanning: " + abc_files[0])
    extract_ts_xforms(alembic.getIArchive(abc_files[0]))

    # go through the remaining files and accumulate the data about the time sampling, xforms and identifying more if necessary vertex deforms
    try:
        for abc in abc_files[1:]:
            print("Scanning: " + abc)
            concat_ts_xforms(alembic.getIArchive(abc))
    except Exception as abc_error:
        print("Error: not able to concatenate file " + abc_error)
        return

    # compute the new TSs
    create_concat_ts()

    # create the concatenate archive
    print("\nCreating:  " + ns["o"])
    out_arch = alembic.getOArchive(ns["o"])
    out_arch.createTimeSampling(final_tss)
    firstFile = True

    # going through each file to append their xforms
    for abc in abc_files:
        print("\t>> " + abc)
        create_output(out_arch, alembic.getIArchive(abc), firstFile)
        firstFile = False

    out_arch = None
    print("\n\n")