docs: def update_part_with_properties(part_instance, moved_instance, name=None):
      """
      Update the newly created part and its properties based on the original one.
  
      :param part_instance: `Part` object to be copied
      :type part_instance: :class:`Part`
      :param moved_instance: `Part` object copied
      :type moved_instance: :class:`Part`
      :param name: Name of the updated part
      :type name: basestring
      :return: moved :class: `Part` instance
      """
      # Instantiate and empty dictionary later used to map {property.id: property.value} in order to update the part
      # in one go
      properties_id_dict = dict()
      for prop_instance in part_instance.properties:
          # Do different magic if there is an attachment property and it has a value
          if prop_instance._json_data['property_type'] == PropertyType.ATTACHMENT_VALUE:
              moved_prop = get_mapping_dictionary()[prop_instance.id]
              if prop_instance.value:
                  attachment_name = prop_instance._json_data['value'].split('/')[-1]
                  with temp_chdir() as target_dir:
                      full_path = os.path.join(target_dir or os.getcwd(), attachment_name)
                      prop_instance.save_as(filename=full_path)
                      moved_prop.upload(full_path)
              else:
                  moved_prop.clear()
          # For a reference value property, add the id's of the part referenced {property.id: [part1.id, part2.id, ...]},
          # if there is part referenced at all.
          elif prop_instance._json_data['property_type'] == PropertyType.REFERENCES_VALUE:
              if prop_instance.value:
                  moved_prop_instance = get_mapping_dictionary()[prop_instance.id]
                  properties_id_dict[moved_prop_instance.id] = [ref_part.id for ref_part in prop_instance.value]
          else:
              moved_prop_instance = get_mapping_dictionary()[prop_instance.id]
              properties_id_dict[moved_prop_instance.id] = prop_instance.value
      # Update the name and property values in one go.
      moved_instance.update(name=str(name), update_dict=properties_id_dict, bulk=True, suppress_kevents=True)
      return moved_instance