cmds.ls(mat=1)
but it’s for all materials in the scene which might be assigned or not assigned to any node.
if you want to know only assigned materials you have find all shading engines which have connection to nodes of type shape probably and after that find their connections to materials
(it was cool to practicing :))
shapes = cmds.ls(shapes=1)
engines = cmds.listConnections(shapes, type='shadingEngine')
materials = cmds.ls(cmds.listConnections(engines), mat=1) # including possible dups
materials = list(set(materials)) # exclude dups
‘shading Engine’ must be in one word (WHEN WILL THIS BUG BE FIXED AT THE LAST?!!!)
So there is no superclass/class system in maya?
I’m trying to get a list of all the lights in the scene, regardless of maya standard or Vray. Garghhh I thought Maya was supposed to be easy to code with
there is a superclass… but it’s exposed to mel (or mel wrapper like cmds and pymel) by using flags in corresponding functions.
in case of ls it’s mat.
using the OpenMaya you have access to ‘superclasses’. but it’s a different story.
Maya does not support the creation of custom plugin lights. The V-Ray lights are actually locators in Maya.
Best regards,
Vlado
I do wish I had the VRaySamplerInfo Render Element in Maya right now, It’d make my life a lot easier!
Generally you do that with an ExtraTex element linked to some output from a samplerInfo node. You can add V-Ray specific attributes to the samplerInfo, which are not present in the original Maya node. There is more info here:
http://docs.chaosgroup.com/display/VRAY3MAYA/Texture+Attributes#TextureAttributes-AdditionalOutputs
(where is says “Additional outputs”)
It’s a few more clicks to set up, but somewhat more flexible. It’s possible to add a render element that will combine ExtraTex+samplerInfo, but we have done it yet.
Best regards,
Vlado
Back into the Maya… learning PySide which is much much friendlier for UIs, I look forward to bringing that to my max tools soon as well in 2017.
I’m still struggling with the lack of class system in Maya.
If I’ve got an object selected in the outline, how do I check the type of this selected object? I need to get the Shape node and test the isType of it… What is the ‘correct’ way to get the shape node of a selected object? Appending “Shape” to the name string doesn’t always work because some should be “Shape” and others should be “Shape1”
import maya.cmds as cmds
selObj = (cmds.ls(selection=True))
if len(selObj) == 1:
theCam = theCam[0]
result = cmds.objectType( (theCam + "Shape"), isType='camera' )
print(result)
Thanks
Dave
excuse me but is this maya script forum ? I believe there’s suitable room in this forum .
Most of the things in this thread have been “this is how we do it in max, how do we do it in maya” and I’ve found this side of the forum has many more people who are dual-software than the other.
if selected object is ‘transform’ you can get shape which uses this transform:
cmds.listRelatives(obj, shapes=1)
so the getting of selected cameras can be as:
def get_selected_cameras():
nodes = cmds.ls(sl=1)
shapes = []
for node in nodes: shapes += cmds.listRelatives(node, shapes=1)
return cmds.ls(shapes, cameras=1)
get_selected_cameras()
PS. but i don’t see any ‘max’ relation in this question. :shrug:
Well for the record… (to help other people on future google searches)
Max vs Maya with Transform and Shape Nodes…
If you’re coming from Maya or you’re learning maya and getting confused as to why in maya there are Transform and Shape node and in max it doesn’t look like there are… here’s a bit of a explanation.
3dsmax has each object as a node in the scene… there is a baseObject property for each node which is where the class of the node is assigned as a MaxObject. When objects are instanced in 3dsmax each node is unique but the baseObject property is shared between the instanced nodes.
When maxscripting, a max node inherits all the properties of the baseObject MaxObject.
example:
$Sphere001.radius = 50
Properties such as:
.renderable
.primaryVisibility
.visibleToReflection
.material
.transform
are on all objects in 3dsmax regardless of their class
Where as properties of the maxObject, such as in an example of a sphere…
.radius
.segs
are unique to the class that is associated with the node as specified by its baseObject Class.
You can use the baseObject property to access these properties as well…
$Sphere001.baseObject.radius.
In the trackview when you look at an object (say Sphere001) you’ll see the Transform controller as subAnims and the “Object” (which should really be called ‘baseObject’).
In Maya these two are separate nodes… the Transform and the Shape Node.
Transform node = maxObject node
Shape Node = baseObject
In the outline you can expose the shape nodes and you can see the shapes as nodes, If you instance a node in Maya you’ll see that the transform nodes are unique but the shape nodes are the same.
In Maya there is not property inheritance like in max… if you select the Transform node, the only attributes you can access are those on the Transform node. You have to get the shape node… which isn’t as simple as just getting the value of a property of the transformNode… (although you can apparently do this with pyMel). As denisT points out above you have to list the relatives of the transformNode filtering by the shape class.