Procedural programming stairs. Have a RuntimeError saying my object is not found?

61 views
Skip to first unread message

Kate Sendall

unread,
Aug 10, 2015, 12:41:06 PM8/10/15
to Python Programming for Autodesk Maya
Here's my code so far. Ignore some of the code that doesn't seem to 'do' anything. It's a work in progress! The problem lies in a complete piece of code/script that should run. I'm putting blue lines in where I think the issue might be:

1.    import maya.cmds as mc
       import pymel.core.datatypes as pym   
 
       #clearing up the scene 
    
       mc.select(all=True)
       mc.delete()

       #defining my User Interface window
10.
       def createSUI():
    
           #checking to see if my window exists and deleting
           if mc.window('myWin', exists=True):
               mc.deleteUI('myWin')
   
           #creating window and setting layout
           windowID = mc.window('myWin', rtf=True, t="Can't Stop Stairing - Stair Maker 2015", backgroundColor=(0.2, 0.2, 0.2), mnb=False, mxb=False, sizeable=True)
           mc.columnLayout(w=400, h=600)
20.    
           #placing banner image
           imagePath = mc.internalVar(userPrefDir=True) +'icons/stairImage.png'
           mc.image(image=imagePath)
           mc.separator(h=5)
    
           #creating my physical in-window sliders
    
           mc.intSliderGrp('stepWidthSlider', l = 'Step Width', v=20, min=1, max=40, field=True)
           mc.separator(h=5)
30.       mc.floatSliderGrp('stepHeightSlider', l = 'Step Height', v=4.2, min=0.5, max=8.0, field=True)
           mc.separator(h=5)
           mc.floatSliderGrp('stepDepthSlider', l = 'Step Depth', v=5.2, min=0.5, max=10, field=True)
           mc.separator(h=5)
           mc.intSliderGrp('numSteps', l = 'Number of Steps', v=50, min=2, max=100, field=True)
           mc.separator(h=5)
    
           #creating my physical in-window button
    
           mc.button(l= 'Make Step', backgroundColor=(0.25, 0.25, 0.25), w=400, h=50, c = 'myStep()')
40.      mc.separator(h=5)
           mc.button(l= 'Make Spiral Stairs', backgroundColor=(0.3, 0.3, 0.3), w=400, h=50, c='makeSpiralStairs()')
           mc.separator(h=5)
           mc.button(l= 'Make Straight Stairs', backgroundColor=(0.35, 0.35, 0.35), w=400, h=50, c='makeStraightStairs()')
           mc.separator(h=5)
           mc.button(l= 'Change Stair Material', backgroundColor=(0.4, 0.4, 0.4), w=400, h=50, c='applyMaterial()')
           mc.separator(h=5)
           mc.button(l= 'Delete All', backgroundColor=(0.45, 0.45, 0.45), w=400, h=50, c='deleteStairs()')
           mc.showWindow('myWin')
    
50.        #fetching data from User Interface sliders

       def myStep():
           mc.polyCube(w = myStepWidth(), h = myStepHeight(), d = myStepDepth(), n = 'myStep')    ~~~~~~~~~~~~
    
       def myStepDepth():
           return mc.floatSliderGrp('stepDepthSlider', q = True, value = True) ~~~~~~~~~~~~

       def myStepHeight():
           return mc.floatSliderGrp('stepHeightSlider', q = True, value = True)    
60.    
       def myStepWidth():
           return mc.intSliderGrp('stepWidthSlider', q = True, value = True)
    
       def numOfMySteps():
           return mc.intSliderGrp('numSteps', q = True, value = True)
    
       #calculating rotate integer for Spiral Stairs from step dimension slider values      
    
       def rotationRadian():
70.       return pym.atan((myStepDepth()-(0.15*myStepDepth()))/myStepWidth()) ~~~~~~~~~~~~
       print rotationRadian()

       def rotationFactor():
           return pym.degrees(rotationRadian())
       print rotationFactor()              


       def makeSpiralStairs():
           i=0
80.       myStep()
           while i < 80:
               mc.duplicate()
               mc.move(0, myStepHeight(), 0, relative=True)
               mc.rotate(0, rotationFactor(), 0, relative=True) ~~~~~~~~~~~~
               i+=1
        
    
       def makeStraightStairs():
           myStep()
90.       mc.duplicate (rr = True)
           mc.move (0, 0.8*myStepHeight(), -0.8*myStepDepth(), relative = True) ~~~~~~~~~~~~
           for i in range (numOfMySteps()):
               #Duplicates the step again using the previous transform
               mc.duplicate (rr = True, st = True)
        
    
       def applyMaterial():
           myShader = mc.shadingNode('mia_material_x', asShader=True)
           mc.select('myCube*')
100.     mc.hyperShade(assign = myShader) 
        
    
       def deleteStairs():
           mc.select(all=True)
           mc.delete()   
    
   

       createSUI()
110.

The error code is exactly: #Error: RuntimeError: file <maya console> line 56: Object 'stepDepthSlider' not found. I don't know what could be wrong? The only difference in stepDepthSlider is that it is used in my rotate function... but so is stepWidthSlider!

Thanks

Kate

Kurian O.S

unread,
Aug 10, 2015, 12:46:41 PM8/10/15
to python_in...@googlegroups.com
First thing don't use your style formatting to post code, its totally not readable :(. Can you put your code in pastebin or some other https://gist.github.com/ . It will much better.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8314ae1e-505e-4c1b-a719-550049e8b279%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Kate Sendall

unread,
Aug 10, 2015, 1:13:56 PM8/10/15
to Python Programming for Autodesk Maya
Alrighty, here we go. I'm not sure how to use these embed things. I hope it works. XD

Kate Sendall

unread,
Aug 10, 2015, 1:17:42 PM8/10/15
to Python Programming for Autodesk Maya
Wow. Just clicked it. Scratch that.
eb97265b58ad25e6df9b-ddcffbb257f38226cf5256153676405f3dc8c3ed.zip

Justin Israel

unread,
Aug 10, 2015, 3:29:16 PM8/10/15
to Python Programming for Autodesk Maya

Please just give the normal url to a pastebin or gist. I'm using a mobile email client and can't use HTML embed codes


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Kate Sendall

unread,
Aug 10, 2015, 3:52:54 PM8/10/15
to Python Programming for Autodesk Maya
Oh... ok. I'm very new to all this. I think this is what you're asking for?
 

 

Justin Israel

unread,
Aug 10, 2015, 5:05:47 PM8/10/15
to python_in...@googlegroups.com
On Tue, Aug 11, 2015 at 7:52 AM Kate Sendall <kate.alic...@googlemail.com> wrote:
Oh... ok. I'm very new to all this. I think this is what you're asking for?
 

Yep, the URL is exactly what you should use, like this. But now you need to do it one more time and not use a private paste :-) 
Can you use public that never expires?
 


 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Aug 11, 2015, 2:11:10 AM8/11/15
to python_in...@googlegroups.com

The first link works, so long as you remove the .js suffix. It will link directly to the file instead.

If you save the file with a .py extension, you will also get Python syntax highlighting.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Aug 11, 2015, 2:45:56 AM8/11/15
to python_in...@googlegroups.com
There are function calls being used in the root of the file which are calling the query functions before the window has even been created:


When I remove those lines, your window gets created and shown. You may still encounter issues with the way you are not saving the full path returned after creating each control, and using those again when querying the values. But for testing purposes, this should get you up and running again.

 

Reply all
Reply to author
Forward
0 new messages