On 10/04/2017 at 10:09, xxxxxxxx wrote:
Hi,
the issue with BuildShaderPopupMenu is that it also contains a bunch of commands, you most like don't want or even worse, which work only in specific context.
It's not that difficult to get the shaders and internally it's done roughly like so:
import c4d
def BrowseShaders(bcShader, bcPath, bp) :
while bp is not None:
if bp.GetType() == c4d.PLUGINTYPE_SHADER and (bp.GetInfo() & c4d.PLUGINFLAG_HIDE) == 0 :
bpId = bp.GetID()
bpName = bp.GetName()
bpFilename = bp.GetFilename()
#print bpId, bpName, bpFilename
bcShader.SetString(bpId, bpName)
if bcPath is not None:
if bpId == 1012158 or bpId == 1012161 or bpId == 1012166 or bpId == 1012160:
bcPath.SetString(bpId, "Sketch and Toon")
elif bpId == 1018767 or bpId == 1018654 or bpId == 1019397 or bpId == 440000050:
bcPath.SetString(bpId, "MoGraph")
else:
bcPath.SetString(bpId, bpFilename)
BrowseShaders(bcShader, bcPath, bp.GetDown())
bp = bp.GetNext()
def main() :
bcShader = c4d.BaseContainer()
bcPath = c4d.BaseContainer()
bp = c4d.plugins.GetFirstPlugin()
BrowseShaders(bcShader, bcPath, bp)
# print collected plugins
print "PlugIns -------------------"
for idx, value in bcShader:
print idx, value
# print collected paths
print "Paths ---------------------"
for idx, value in bcPath:
print idx, value
if __name__=='__main__':
main()
The main part is then the sorting, which I don't want to post here (and actually don't want to port to Python). That's also the reason for bcPath to be filled. So it's not that tedious.