0
$\begingroup$

I am trying to create add-on in order to control the color from RGB node and struck at how to hide the custom Properties with the material of the selected object does not have included the RGB node. Let's say the Plastic material has included an RGB node, the diffuse color parameter is shown; while the other material(which does not have included an RGB node), the diffuse color won't be shown in the property panel enter image description here enter image description here

My command is like this:

 class MaterialParameterPanel(bpy.types.Panel):
    
    bl_label = "Material Color"
    bl_idname = "MATERIAL_PT_PANEL"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Material Parameter"
    
    def draw(self, context):
        layout = self.layout
        ob = bpy.context.active_object
        ma =ob.active_material
        row=layout.row()
        row.prop(ma.slot_setting, "rgb")


def updateRGB(self, context):
    mat = self.id_data
   node = mat.node_tree.nodes
   nodes = [k for k in node
           if isinstance(k, bpy.types.ShaderNodeRGB)]
            
   for k in nodes:
        k.outputs[0].default_value = self.rgb
    
       
    
class rgbSet(bpy.types.PropertyGroup):
    
     RGBisTrue: BoolProperty(...)
     rgb: FloatVectorProperty(....
     update=updateRGB)


                

            
def register():
    bpy.utils.register_class(MaterialParameterPanel)
    bpy.utils.register_class(rgbSet)
    bpy.types.Material.slot_setting=PointerProperty(type=rgbSet)



def unregister():
    bpy.utils.register_class(MaterialParameterPanel)
    bpy.utils.register_class(rgbSet)
    del bpy.types.Material.slot_setting

if __name__ == "__main__":
    register()

            
$\endgroup$
2
  • $\begingroup$ Hello, please add a screenshot of what you are trying to hide $\endgroup$
    – Gorgious
    Dec 10 '20 at 10:31
  • $\begingroup$ I have added two screenshots to explain what I am trying to hide $\endgroup$
    – Kayla Man
    Dec 11 '20 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.