Lecture Notes 28/11/22
Alright, so this will be a post of me recapping old stuff in Python to try and force it into my braincase, and coding what I can in Maya. Going through W3Schools and using the python reference guide for Maya, trying to quickly recover the code to make a cube class and execute it without a litany of errors. Python would be a lot easier if I could actually remember it between lectures, feels like I almost have to relearn it every week.
So far, all I've managed to accomplish in Python overall is a very basic understanding of it's structure and functions, using it to create multitudes of basic poly objects within Maya itself and animate them on a basic 'move along x/y/z' path. While its better than nothing, its still nothing I couldn't just create in Maya in less time without touching the script editor. The one very useful thing I've found so far though is the ability to make a long row of evenly spaced objects, which can be handy. However, similar function exists within Maya with MASH, so not exactly groundbreaking. But I know there will be more advanced and useful stuff later on, I just have to wrap my head around this crap. At the moment I'm just trying to figure out how to get this cube I have created with a class to move.
With Stoychos recommendation, and common sense, I've gone over my old code and commented on it, so future me can figure out just what it does without spending half an hour trying to guess. My main hangup at the moment is the animation range class we made a few lectures back. It sucks because I know I'm behind on this, but I need to figure this out. This here is the code:
def Create_Animation(self, Animation_Range): #class for basic animation
cube = cmds.polyCube(w = self.Width, h = self.Height,d = self.Depth)
for i in range(Animation_Range):
cmds.currentTime( (i+1)*10, edit=True ) #creates a keyframe every 10 frames
cmds.setKeyframe(cube,v=i, attribute="translateX") #'v' flag overrides default keyframe values
I figured out that i is insert, at is attribute and v is value by checking the command documentation. Plus, it works, but I think that was because this is stoycho code. What I can't seem to figure out is just what governs how far along the x axis it moves with the translate command. It moves up to 11, which leads me to believe that it's related to the i value in the 5th line, but sometimes it goes to 48 when I run it, and I have absolutely no idea why. I mean this module is programming for animation, so if I can't figure this out, I'm fucked. This stuff is basic, but it may as well be japanese.
Never mind, I figured it out, I'm a dumbass.
I was looking in the wrong place. The code I pasted is literally just to make the class, and how many keyframes I want it to bust out. The actual command at the bottom is for both making, and translating it. Now to figure out how to move it full stop, without animation rather than having a smorgasbord of various cubes all spawning at the origin point.
Programming for Animation
Status | Released |
Category | Other |
Author | Ionasphero |
More posts
- Lecture Notes 28/11/22 Missing CodeDec 15, 2022
- Lecture Notes 07.11.22Dec 15, 2022
- Lecture Notes 24/10/22Dec 15, 2022
- Pre-Quiz Revision NotesDec 15, 2022
- Final Post before SubmissionDec 15, 2022
- Lecture notes 10/10/22Oct 10, 2022
- Lecture notes 03/10/22Oct 10, 2022
Leave a comment
Log in with itch.io to leave a comment.