Record "Absolute file path (Duf) " when import, and keep it as scene property of current blend file

Issue #80 resolved
engetudouiti created an issue

After import daz scene, and save it as blend file, we may often forget which file we import.

Then current add on offer “Relative path” from daz library as object.DazID .

but it only work, when you remember which library you save the duf (and json). as you know, when we export json, we use “absolute path”. i

I made script, when select daz mesh, and click button, it read current select object.DazID.

and change it as json file path (json) and set it as bpy.context.scene.js_path

it change with current selected objects.

But to use the property to auto open the file directory, in Blender File Browser,

it need to set absolute path. though I temporally make it

“bpy.context.scene.DazPath1” + “bpy.context.scene.js_path” as file path to open blender browser,

then it worked.

but it only work, when the duf are exported in DazPath1 . if it is saved in DazPath2, DazPath3, etc,

it never work.

I assume you use relative path, for visilbility issue , (too long string, to show in labell)

but, I really hope you offer one more scene custom property which actually keep full path of the duf. please.🙂 then I customize it to open the json file path, without serch around directory, in blender file blowser. (it is ok not shown in panell, just need to get the absolute path, as object property

(eg,, bpy.context.active_object.DazDufPath )

Comments (10)

  1. engetudouiti reporter

    Sorry,, I could find each mesh already keep, import duf file,as DazID, I just serched it with armature,, but it seems more reasonable, to keep duf url as mesh DazID.

    Thanks, I could manage it as json file path. Only issue for me, to use the DazID, I need to select each mesh, once. (I hoped to auto-open the file in blender file browser, when select rig )

  2. Thomas Larsson repo owner

    The plug-in loops over the Daz root paths, and stops when it finds a file. So it tries:

    1. scn.DazPath1 + relpath
    2. scn.DazPath2 + relpath

    until it finds a file that exists, using the function os.path.exists. Can’t you do the same?

  3. engetudouiti reporter

    Yes if there is no other way, I suppose I try to use loop. actually I planned it.

    but Using loop to set absolute duf file path of current scene, select mesh, seems something strange for me,

    because when export/ import duf scene with json, we can choose any library and directory as we like.

    Though I do not know detail, how you catch the DazID, (from scene duf, or json, or dsf in data etc),

    But I suppose you already get absolute path, when you loop ,,

    so attach the absolute path for mesh make things more complex?

    if you can do it (just do not hope to add new props,, ) actually keep

    absolute path seems more usable. when we serch the original file.

  4. engetudouiti reporter

    I now try to use loop, to get all directory path which user may change,

    then I see, I can get the dir_index = scn.DazNumPaths

    but how you can loop to set scn.DazPath1 , scn.DazPath2, scnDazPath3 ,,,,, with dir_index?

    the DazPathX s, not attribute of list..

    eg if you make each librafy paths as list, scn.DazPaths[0] ,scn.DazPaths[1],, ….scn.DazPaths[dir_index-1],

    I can easy get the path with loop. but you did not make so,, then set prop by layout.box.prop()

    for n in range(scn.DazNumPaths):
        box.prop(scn, "DazPath%d" % (n+1), text="")
    

    but I can not find way, to loop from scn.DazPath1 to DazPathX, with the index count.

    and set the file path, for each DazPathX. 😫

    I really apreciate, if you teach some basic, how manage about this case..

    I am now editting this function,, (to set the file path in blender browser)

        def invoke(self, context, _event):
            scn = context.scene
            bpy.ops.dazinfo.reflesh()
            rigs = bpy.context.selected_objects
    
            if not rigs:
                msg = "Select import rigs first!!"
                showInfo(self, context, msg)
                return {'FINISHED'}
    
            dir_count = bpy.context.scene.DazNumPaths
            for i in range(dir_count):
                dir = "DazPath" + str(i)
    
            #how to get actuall DazPath1 to DazPathN value?             
            #I will try to serch the "bpy.context.scene.js_path" for each dp (directory) which I assgin in the class.            
    
            #self.filepath = bpy.context.scene.DazPath1 + bpy.context.scene.js_path 
    
            context.window_manager.fileselect_add(self)
            return {'RUNNING_MODAL'}
    

  5. engetudouiti reporter

    Ah OK I could use getattr(scn, pathstr) to check and return the file path.

    I may try thanks.. (but still expect,, if you will add absolute file path as new mesh.property @@;)

  6. Log in to comment