The legacy unfold command normally takes numbers between 5000-10'000 iterations to get a good unfold.Īlso, I should probably mention, that your unfold needs to be flawed for the unfold flag to do anything, if you test it on the default UV's of a cube for example, the UV's are already in their optimal positions so unfolding doesn't change them. What you need to change for the UV to unfold, is the "iterations" (i) flag in your unfold command, currently it is set to 0. If that is what you want, great you're done!ġ) that the object you're using the command on has existing UV'sĢ) that those UV's aren't all at the same positionīut I'm assuming, that you want your UV's to unfold, because if you wanted to simply scale the UV's you could have used the scale command on the UV ID's. What your script currently does, is take an objects UVs and scale them to your ratio "Texel Density"/"Texture Resulotion". Well, depending on what it should do, which I don't know because you didn't tell me. There isn't really a problem here, your script works. Example1: import maya. I also changed the variable created by the for loop so it doesn't clash with the "i" flag (eventhough that didn't seem to cause problems.) 1) maya.cmds.1s () retrieving a list of nodes in the scene.
#MAYA PYTHON LS CODE#
So here is the code with correct indetation for anybody else who wants to give it a go:Ĭmds.unfold(obj,i=0,ss=0.001,gb=0,gmb=1,pub=0,ps=0,oa=0,us=1,s=scalar) ''' INITIALIZE FRAME LAYOUT AND FORM LAYOUT'''Ĭmds.frameLayout("FBX_Exporter_UI_animationFrameLayout", collapsable=False,label="",borderVisible=False)Ĭmds.formLayout("FBX_Exporter_UI_animationFormLayout",numberOfDivisions=100,parent="FBX_Exporter_UI_animationFrameLayout")Ĭmds.text("texelDensity",l="Texel \n Density",parent="FBX_Exporter_UI_animationFormLayout")Ĭmds.floatField("density",minValue=0, precision=1, step=1,w=100,h=30)Ĭmds.text("textureResolution",l="Texture \n Resolution",parent="FBX_Exporter_UI_animationFormLayout")Ĭmds.floatField("resolution",minValue=0, precision=1, step=1,w=100,h=30)Ĭmds.button("apply",l="Apply",h=30,w=70,c=applyScale)Ĭmds.formLayout("FBX_Exporter_UI_animationFormLayout",edit=True,attachForm=)įirst off, please when you post code, use a codeblock ( button) otherwise the code loses its formatting, which isn't optimal, especially for python code because indentation matters. Window_demo = cmds.window(winId,t="Layout Design",w=500,h=500,menuBar=True) ''' CREATES NEW WINDOW WITH SPECIFIED WIDTH AND HEIGHT''' ''' CONDITION WHICH CHECK EXISTENCE OF WINDOW''' TxDensity = cmds.floatField("density",q=True,value=0) # If there are no relative, return an empty list (or ), so that we always get a consistent object type outputĬhildren = cmds.With the below code there is no error but it doesn't work, in this, I am creating GUI in which two inputs density and regulation when I click on apply button it doesn't work and it gives me no error if anyone has an idea to solve please guide or help me, Thanks.
#MAYA PYTHON LS FULL#
# We want to list the relatives, we only want the children, and we want the full path # Lets create a new variable to store the relatives # For each object now in the 'selection' variable # In reverse, giving us the longest path first # Sort the list now stored in 'selection' # dag=True : We will only get objects which are listed in the outliner, and none of the hidden objects inside of Maya. # long=True : Gives us the full path to the object, so we can determine any parents. # Then get all objects in the outliner and assign to 'selection' To get the actual object type (mesh, joint, nurb etc.), we need to add a few more bits to our code (here is the full commented code): Load the maya commands library from maya import cmds Create a new variable 'selection' Store in it the currently selected objects selection cmds.ls (selectionTrue) If the selection contains 0 lists if. # Store in it the currently selected objects To get the actual object type (mesh, joint, nurb etc.), we need to add a few more bits to our code (here is the full commented code): # Load the maya commands library This is just how Maya represents it objects, however is this really useful to us? See. When we run this script you’ll notice that the output is ‘transform’, why is that? Notice the indentation ?, the print command is within the for loop, so in each iteration, the command will print the objectType for each object. Let’s add a command to print the object type for each of the objects in the for loop above: from maya import cmds If you intend to run this code, be sure to add a few objects to your maya scene, for this example we have added 3 different mesh objects (cone, 2x cube, cylinder). This is used to find the type of an object.