Using "definition.import" to import .dae files only works locally

Using “definition.import” work when importing local .dae files from "C:". But when I try to use the same code to import the same files on a network space it throws this error:

#<IOError: Failed converting file to SKP>

Has anyone else had this problem before?

I can import .skp file from the same space with “model.definitions.load” so it’s not an access problem.

In many case over the years, we’ve found that the SketchUp API to be susceptible to network latency issues.

If loading a .skp file from a network path, code should use Sketchup::DefinitionList#load_from_url() with a LoadHandler object (as shown in the documentation for this method.)

For import of non-SKP files, it would likely be best to use the Sketchup::Http::Request to download the file to a local disk location (Downloads folder or wherever, see Sketchup::temp_dir,) … and then do the local import using Sketchup::DefinitionList#import().
After a successful import, code should probably delete the temporary downloaded file. See File::delete in the Ruby core documentation.

1 Like

Thanks, I went for the download to the temp_dir approche. It works well :slight_smile:

1 Like

I opened a feature request issue in the API tracker at GitHub for a new import_from_url method for the API’s DefinitionList collection.

REQ: Sketchup::DefinitionList#import_from_url · Issue #900 · SketchUp/api-issue-tracker (