Could you make load daz materials work on all selected materials

Issue #1626 resolved
Joe Morris @ FAST Animation Studio Toolz created an issue

I think a load daz materials function should work on all selected objects I'm gonna go ahead and write something real quick but that would be cool

Comments (6)

  1. Thomas Larsson repo owner
    • changed status to open

    You can already import multiple materials; just select several files in the file selector.

    If you mean that you want to assign the same materials to several meshes, that can be done with the Copy Materials tool instead (after last fix).

    1. Import materials to one mesh.
    2. Copy the materials to the other meshes.

  2. Joe Morris @ FAST Animation Studio Toolz reporter

    this is what I mean the way your code for import dazz materials is designed it only works on one material at a time but I had errors all over this entire hotel lobby because I imported it with an earlier version of diffeomorphic so it had undefined nodes everywhere so I had to replace the materials on everything and I wanted to do it in one step so this is what I wrote that I was suggesting you do this too

    class FAST_OT_import_daz_materials_to_selected(bpy.types.Operator, ImportHelper):
        """Import DAZ materials from a DUF file to all selected objects"""
        bl_idname = "fast.import_daz_materials_to_selected"
        bl_label = "Import DAZ Materials"
        bl_options = {'REGISTER', 'UNDO'}
        
        # ImportHelper mixin class uses this
        filename_ext = ".duf"
    
        filter_glob: StringProperty(
            default="*.duf",
            options={'HIDDEN'},
            maxlen=255,  # Max internal buffer length, longer would be clamped.
        )
        
        def execute(self, context):
            try:
                import import_daz
            except ModuleNotFoundError:
                self.report({'WARNING'}, "The import_daz module is not found. The Diffeomorphic add-on might not be enabled.")
                return {'CANCELLED'}
            
            import_daz.set_silent_mode(True)
            
            # Make sure all mesh objects are selected
            for obj in context.selected_objects:
                if obj.type == 'MESH':
                    # Make the object the active object
                    context.view_layer.objects.active = obj
                    import_daz.set_selection([self.filepath])
                    bpy.ops.daz.import_daz_materials(
                        skinColor = (0.600,0.400,0.250,1.000),
                        clothesColor = (0.090,0.010,0.015,1.000),
                        materialMethod = 'BSDF',
                        useReplaceSlots = True,
                        useAddSlots = True,
                        useMatchNames = True
                    )
                    obj.select_set(False)  # deselect the target after operation
    
            return {'FINISHED'}
    

  3. Joe Morris @ FAST Animation Studio Toolz reporter

    And just one more quick note is I run into this issue and using diffeomorphic where I try to import something and it doesn't come through right and it's because I don't have my asset library set… If you guys implemented some sort of test that would you know read the DUF file And compare it with what's been imported and then if those things don't match up then put a self report.info saying that you must not have added your asset libraries correctly I could say people a lot of time… new users… Or doesn't the DUF file have the path information i'm pretty sure it does maybe even bring up some sort of dialog you know saying that this is the path that it's looking for and that these files aren't there.. And I've been testing this for a while windows has Everything software it's like an instant search tool for everywhere in your hard drives partitions and external hard drives and they have an API you know what would be really awesome because you guys write such complex code would be to implement their API and then when you're bringing in a file if it's not there search everywhere… I'm getting ready to start utilizing that tool more often... I was gonna write a better find missing files operator because with their API you don't have to give it a specific folder just one click and like instantly it would find and start adding all those materials to your blender file….. So due to the complex libraries setup of Daz Studio this could be a really good option… I provide a bonuses folder to my end users on gum road and I've been supplying Everything.exe in that folder for a long time nobody's cared.

  4. Log in to comment