Help finding a shader node group.

I have a blend file with various objects in using shader node groups, I have looked through manually and cannot find a shader group but it is listed as being avialable.
The group in question is a duplicate of an existing shader group and so I want to “tidy up” the file so only the one occurence exists. I am looking for a “fresnel.001” which isn’t showing up anywhere.

I can find lost of exampled of how to createshader groups in python, but none which allow you to locate them.
I had thought I could use a script to check all materials and list them that way, but I’m not sure if it is only listing some, or the “top most” shade group.

Is there any way to check for the existence of a specific shader group and find out it’s users?

Below is the script I’m using to list shader groups, but I’m not sure how effective it is.
Can anyone offer advice / assitance please?

– CODE ----------------------------------------------------------------------------

List use of nodegroups in materials with any luck!

import bpy
import os

os.system(“cls”)
main_path = os.path.dirname(bpy.data.filepath)
filename = “NodeList_Maybe.txt”
outputfile = os.path.join(main_path, filename)
w_file = open(outputfile, ‘w’)

tmpStr = "
List of nodes maybe:
(Shadergroup - Material)

"
print("

Writing to: " + main_path + "
")
w_file.write(main_path)
print(tmpStr)
w_file.write(tmpStr)

materials = bpy.data.materials

for mat in materials:
try:
nodes = mat.node_tree.nodes
except:
continue
for node in nodes:
try:
ntree = node.node_tree
except:
continue
tmpStr = “{0:35} - {1}”.format(node.node_tree.name, mat.name)
print(tmpStr)
w_file.write(tmpStr+"
")

w_file.close()

– END CODE -----------------------------------------------------------------------

Example output:

Writing to: G:\Blender_Resources\Colkai_Blends\Arch_Viz

List of nodes maybe:
(Shadergroup - Material)

PBR (Surface) Metallic - BrassDoorHandle
DoorHandleScrews - BrassScrew
DoorLatchWithScrews - DoorLatch
PBR (Surface) Diffuse - DoorLatchbit
PBR (Surface) Metallic - DoorLatchBitBr
DoorLatchWithScrews - DoorLatchBlk
PBR (Surface) Metallic - Hinge
PBR (Surface) Metallic - KitchenSpotBulb
PBR (Surface) Metallic - KitchenSpotChrome
PBR (Surface) Glass Shader - KitchenSpotGlassOFF
PBR (Surface) Metallic - LeftHingeUvd
PBR (Surface) Metallic - RightHingeUVd
RollerLatchGrp - RollerLatch
RollerLatchGrp - RollerLatchScrew

Forgot to attach the blend file so people can interrogate it, sorry.

would be nice to set the renderer first
bl or cycles !


# Make renderer as Bl or cycles

if bpy.context.scene.render.engine=='BLENDER_RENDER':				# Select renderer
	print ('Render is = BLENDER_RENDER')

#	print ('Converted to BLENDER_CYCLES')
else:
	bpy.context.scene.render.engine="BLENDER_RENDER"
	print ('Render is = Blender')



happy bl

master list is the master list of all mat in file
nothing to do with object

each object has a list of mat
so you need to list all object and find if one mat is being used on more then one mat !

do you need to do that for all mat group ?

happy bl

Sorry for the late reply, been tied up with other matters.

Setting the renderer makes adifference then? I am new to coding in Python / Blender so must admit, I am learning by trial and a lot of error. :stuck_out_tongue:

Yep, I know the master list is all materials, I was using that to find ones defined but then not actually used anywhere.

Ideally, I am after parsing the master list, then trying to find objects using that material.
In a simplistic world, it would be like…

isfound = false
foreach material in materials
foreach object in objects
if material in object.materials then isfound = true

So I could remove the materials or list which objects they belong to.
I’m sort of part way there but it seems to me some things can be “hidden” or “false readings” and from what I can gather, that happens a lot if you have a linked object / group you have appended but then renamed or repurposed. It seems the original definition still hangs around even though there is no actual mesh / object.

I noticed if I look at groups in the outliner, expand them and try to click on an object, if it can be selected it is ‘real’, if not, it seems to be a ghost material / shader of some sort and you have to go through a lot of “orphan” clean up stages to remove it. It would be really nice to isolate this sort of things and kill it automatically.

not certain about that hidden things !
do you have sample file for that !

only thing is that mat will stay if it is Fake user
otherwise when you close file it will be removed

happy bl

I did post a previous example with the “hidden” thing, well, not technically hidden as if you look in groups they are there but don’t seem to belong to anything.
Here’s a link to the thread, as I say, pretyt much related to this, I could be asking for something that is not doable in Blender with Python, but being used to C# / C++ I assume there is always at least one way to get the result. :stuck_out_tongue:

http://www.blenderartists.org/forum/showthread.php?382935-Strangeness-with-ghost-object-datablocks

not certain if mat and texture are sort of link to datablock in group and made fake user somehow!

given link seems to show one way to clean up things for group at least

is it enough or need other script to clean up other things for mat in cycles or bl ?

happy bl

I can manage with cleaning up bit by bit with Orphan Slayer and I agree with you, it seems that somehow, groups make things “fake user” when linked. Could be I am asking too much for cleaning up node groups and materials. I’ve found over the last day or so, I first have to remove the unused material, only then does the problem node group become “visible” as an orphan, then I can use orphan slayer to remove it. My gut instinct now is, there would be too much recursive action of objects / materials / nodes to make this viable when a bit of “donkey work” with orphan slayer will tackle it, would of been nice though but I doubt my python skills are up to it. :slight_smile:

may be ask question on

or make a bug report and see answer !

but I don’t think fake user are made with group
strange behavior !
PM me if you find what the problem is !

in latest built 2.77 also there will be a new lib delete thing
not certain if this will change things may be

happy bl