nerk987 / txa_ant

Textured version of the A.N.T. Landscape blender addon
86 stars 10 forks source link

The path to presets and materials is lost if you put the addon in a custom scripts folder #3

Closed Oxervision closed 4 years ago

Oxervision commented 4 years ago

Hi, the first thanks for the addon!!

Like title says if you put the addon folder in a custom scripts path, you lost the path to presets and materials.

I have a custom addons folder so I have all the addons available for all Blender versions in a single place. I set it in Preferences > File Paths > Scripts. This evits have copy of all addons in the default addons folder of each version of Blender.

I fixed the materials path changing the lines 109 and 112 in _antfunctions.py file: • Original line 109: filename = bpy.utils.user_resource('SCRIPTS', "addons") + sep + "txa_ant" + sep + "materials" + sep + "island" + sep + PrefMat + ".json"

Changed Line 109: filename = os.path.join(os.path.dirname(__file__), "materials" + sep + "island" + sep + PrefMat + ".json")

• Original line 112: filename = bpy.utils.user_resource('SCRIPTS', "addons") + sep + "txa_ant" + sep + "materials" + sep + PrefMat + ".json"

Changed Line 112: filename = os.path.join(os.path.dirname(__file__), "materials" + sep + "island" + sep + PrefMat + ".json")

I don't know how fix the path to the mainpresets and presets folders.

I hope you can help me,

Thanks in advance!!

Oxer

macOS 10.13.6 & Blender 2.83 LTS

nerk987 commented 4 years ago

Hi Oxer,

I'll take a look and see what I can do. Presets in Blender seem pretty confusing to me, and they seem intended to allow users to save presets rather than the addon provinging them.

Oxervision commented 4 years ago

Ok, thanks!!

nerk987 commented 4 years ago

Now works for me in Windows with version v2.81.5, so closing the issue. Let me know if there are further issues.

Oxervision commented 4 years ago

Hi, thanks for the updating!!

I tested it and the materials path works but folders of main & erosion presets aren't recognized.

Erosion Presets - Unrecognized Path Main Presets - Unrecognized path

nerk987 commented 4 years ago

I might need your help with this one then. It works on my Windows machine with no changes to the original code.

The lines in question are in ant_functrions.py, lines 1085 and 1086:

preset_subdir = "../addons/txa_ant/presets"

and preset_subdir = "../addons/txa_ant/mainpresets"

The paths work a bit differently here compared to the other areas. It doesn't matter if I use a linux/Mac '/' or a Windows '\' it still works, but if I use a 'C:\' in the string, or a 'os.path.dirname(file)' function, it throws an error. If I make an error in the path, there is no error, but the presets are missing like your images.

When I created a custom scripts folder, I copied both the 'presets' and the 'addons' directory from the 'Blender\2.83\scripts' directory. I'm wondering if you don't have a 'presets' directory in your custom scripts path. The relative path in the above code moves up one directory from the presets, then down to the txa_ant directory.

If that's not it, would you mind playing with the path in those lines to see if you can make it work.

(p.s. There's a duplicated line on 1084 which I've now deleted.)

Oxervision commented 4 years ago

Excuse me for not answer you before, I had problem with my internet connection. I copied the presets default folder to my scripts custom folder and the presets are showed now! 👍

A menor problem, when you save a preset, this is saved in the default path: /Users/User/Library/Application Support/Blender/2.83/scripts/addons/txa_ant/presets

Thank you very much for your time and efforts!!

Regards