hexagon logo

Create Parts from file input

I have text file which contains name of the parts and path to respective part child geometries.

Is it possible to create parts and import geometries under respective parts by text file input.

Parents
  • One option would be to create a python script that parses part_list.txt and then calls the Parts.createRigidBody() and Adams.read_parasolid_file() function.  See the Adams Python Classes Reference, available in the Documentation:

    Adams Basic Package > Adams View > Adams Python Interface > Adams python classes reference

    Here is an example:

    import Adams
    
    file_name = 'part_list.txt'
    
    with open(file_name) as f:
        lines=f.readlines()
    
    part_names = [line.strip() for line in lines[::2]]   #every other line from elem0
    paths = [line.strip() for line in lines[1::2]]       #every other line from elem1
    
    m = Adams.getCurrentModel()
    for part_name, path in zip(part_names, paths):
        m.Parts.createRigidBody(name=part_name)
        Adams.read_parasolid_file(file_name=path, part_name=part_name)

  • One question what is command for step file or other cad formats.

Reply Children