[Closed] Using Refs.dependents in GetClassInstances
I’m using “GetClassInstances” a lot to get textures by class, but I’m having trouble using “Refs.dependents”, basically the function I do is pass the input of this texture taken with “getClassInstances” to the input of the next texture , just removed that texture from the nodes but continuing the sequence.
The image exemplifies the result I want. Only using “GetClassInstances” and not $.material.slotnode…
the code I’m trying is something like this:
CCCMaps = getClassInstances CoronaColorCorrection
for CCCcount = 1 to CCCMaps.count do
(
refs.dependents CCCMaps[CCCcount] = CCCMaps[CCCcount].Map
)
Thanks your attention.
I want to achieve the result on the right, that is, disconnect the maps from getclassinstances without changing the rest of the material, in the example there is the mix that instead of connecting to color correction will connect directly to the material, removing the color correction from the material.
Here’s an example how you could do that
cc = getClassInstances ColorCorrection
for c in cc do
(
for d in refs.dependents c do
(
for prop in getPropNames d where isProperty d prop and (getProperty d prop) == c do
(
setProperty d prop c.map
)
)
)
thanks, it worked great, I still researched how to delete this material after that and I got it too.
here until the code later to delete for when someone needs
cc = getClassInstances ColorCorrection
for c in cc do
(
for d in refs.dependents c do
(
for prop in getPropNames d where isProperty d prop and (getProperty d prop) == c do
(
setProperty d prop c.map
)
)
)
for viewIndex = 1 to sme.GetNumViews() do
(
smeView = sme.GetView viewIndex
smeView.SetSelectedNodes cc
smeView.DeleteSelection()
)
this is the right way to do it:
for c in getclassinstances colorcorrection where iskindof c.map texturemap do replaceinstances c c.map
I have to agree that this solution doesn’t always work as originally requested… use the second one
Sure, but it replaces the original color correction node with texmap from .map slot and the result may confuse average user, cause it still shows that the map is ColorCorrection in SME (must be a bug)
just the opposite. confuses – when the connection is maintained, but it is not connected anywhere next…we delete this Color Correction after that anyway
maybe it can make sense sometimes … so, check this one:
for c in getclassinstances colorcorrection astrackviewpick:on do
(
refs.replaceReference c.client c.subnum c.anim.map
)
I appreciate the productive discussion about the best method.
I tested everything you guys are saying.
for c in getclassinstances colorcorrection where iskindof c.map texturemap do replaceinstances c c.map
For this method above I got results but it created a “copy” of all maps and they were left over in the SME. So it wasn’t so promising as I would have to find a way to delete them from the SME.
for c in getclassinstances colorcorrection astrackviewpick:on do
(
refs.replaceReference c.client c.subnum c.anim.map
)
For this method above I didn’t get results because for some textures “error unknow property client” appeared. The purpose of the code is to be able to use it with any type of texture, using a variable in the input property. Which in this case is being “.map”.
Even if the other initial code is bigger and more complex is the one that gave the most results, if you can tell me how to use this last code correctly I’ll substitute for the simplest and most effective code.
for c in getclassinstances colorcorrection astrackviewpick:on where c.client != undefined do
(
refs.replaceReference c.client c.subnum c.anim.map
)
additional test is required in case some color correction textures are not bound to anything, so they do not have a client