ian-m-carr / XPlane2Blender

Scenery & Aircraft export addon for Blender and X-Plane
GNU General Public License v3.0
2 stars 0 forks source link

Import issue with absolute/relative paths #2

Open JT8D-17 opened 6 months ago

JT8D-17 commented 6 months ago

Originally posted here: https://github.com/X-Plane/XPlane2Blender/issues/728#issuecomment-1850657050

Issue:

Opening a Blend file and then trying to import an object always end sin this error:

File "/home/[username]/.config/blender/4.0/scripts/addons/io_xplane2blender/xplane_import.py", line 63, in execute x = xplane_imp_parser.import_obj(self.filepath) File "/home/[username]/.config/blender/4.0/scripts/addons/io_xplane2blender/importer/xplane_imp_parser.py", line 91, in import_obj relpath = Path(filepath).relative_to(Path(bpy.data.filepath).parent) File "/media/X-Plane/X-Plane_Utilities/blender-4.0.1-linux-x64/4.0/python/lib/python3.10/pathlib.py", line 818, in relative_to raise ValueError("{!r} is not in the subpath of {!r}" ValueError: '/media/X-Plane/X-Plane_12/Aircraft/AddOn_Aircraft/B737-800X/objects/738fuselage.obj' is not in the subpath of '/home/[username]' OR one path is relative and the other is absolute.

The only thing I can do then is restart blender and importing into an empty Blender file.

@ian-m-carr's reply:

The importer requires the blender file to be in the same heirarchy as the obj files it is importing. Looks from your error that this was not the case. Can you open an issue on the fork, and tell me the paths 1: to the blend file (must have been saved!) and 2: to the obj file you are importing (must be a path below the blend location, I often use a symbolic link or windows junction to arrange to have the aircraft folder appear below the blender modelling folder)

Continuation:

Blend file path:

/home/[username]/untitled.blend

Imported file path:

/media/X-Plane/X-Plane_12_Main/Aircraft/AddOn_Aircraft/B737-800X/objects/rain_glass.obj

How many importer infrastructure changes would be required to get rid of the "must be the same hierachy" requirement?

ian-m-carr commented 6 months ago

Thats the way the Laminar code works.

If you'd like to take a look at the code I could consider a pull request.

My solution as I mentioned is to symbolically link an "export" folder below my blends to the aircraft obj folder. I then import/export everything through that.