blender scripting questions


#1

I have been boiling with questions on blender python scripting. Does anyone do blender scripting here? This is one area I’m going to be spending quality time, in the near future, … and I’d appreciate a forum where I can cross-pollinate. Shouldn’t there be a “blender scripting” sub-forum? Here comes the first one:

In MAX, one could access the location of a selected object by typing in the listener:

$.pos

How is it done in blender?


#2

There probably aren’t as many people doing scripting here as they are at BlenderArtists in the Python & Plugins subforum:
http://blenderartists.org/forum/forumdisplay.php?f=11

 Additional information regarding the API can be found at the wiki:

http://www.blender.org/documentation/250PythonDoc/contents.html

About your “location” problem you’ll have to get an answer from someone else than me, someone who actually knows python :slight_smile:


#3

in blender 2.5 you can do:

bpy.context.object.location

it gives you the location of the selected (or active, in multiselected) object.

or

bpy.data.objects['name of object here'].location

to get the location of an object by name.

some usefull links:

blender 2.5 api
API intro


#4

[font=Verdana]

Thank you so very much.


#5

I posted the following at www.blenderartists.org, I’m putting it here just in case:

I’m looking for a script with two functions i[/i]. One copies the properties (e.g. orientation) of a selected bone/object and the other pastes the copied data to a new bone/object. Has anyone scripted this before? If so … care to share? Or, … a lead on how to go about creating such would be appreciated.


#6

Why do you need for this a script?

Also, BlenderArtist is not so great. I once posted there a question and no one even looked inside the thread for a month as of today.


#7

maybe this can help,

http://tube.freefac.org/post/copy-menu-redux


#8

I prefer to have some coplanar bones in a hierarchy facing a certain direction . Sometimes child bones don’t transform as expected in Blender. I need a tool that allows a copy of a bones orientation/location (not pose) an can paste same orientation/location unto another bone.

I’ve likewise observed that phenomenon.

Almost perfect. The code is a good reference point as it exemplifies scripting for Blender 2.5 integration. However, it focuses more on copying poses & locations (bone section). what I need is something that deduces orientation of bones based on locations of their heads & tails, store deduced angles, and use those angles to determining bone rolls for perpendicular bones the hierarchy. I’ve started scripting the desired tool anyway


#9

Yeah, that’s because the thread view counter at blenderartists.org forums is broken… :slight_smile:


#10

Someone should alert the administrators

Okay! I decided to float my thoughts, as usual, and see what the gurus will say. I get the feeling that my forerunners have been through this path and have overcome; which begs the question, “Should I even be writing a script for this?” Just wondering …:curious:

Blender is blessed with tutorials. Traditionally, rigging a Character’s legs start on either the left or Right viewports. Adjustments may later occur in other views. I have seen excellent blender tutorials on leg rigging executed solely on the side views. Now the target audience (and new immigrants … like me) may have a character with legs apart and toes almost at 45 degrees (viewing from top). That posture – common default rigging posture – cannot be fully comprehended without paying attention to the front/back views. The newbie is left to innovate. He thinks, “What if I set the bones right and apply the techniques I gathered from the tutorials?”. Aah! Good idea.

So, we have the hierarchy - b[/b] which is coplanar to the YZ-plane. It appears as a straight line at the front view (XZ-plane). This is the hierarchy the newbie had prepared to digest his tutorials … now he must adjust it. He begins with an A-select to highlight the lot. With cursor snapped to the hip joint, he does an R-rotate (about the Y-axis) until the bones seem to fall in place at the front view. The resultant is the hierarchy - (B). A careful look reveals that the bone rolls no longer agree. By this time, I’m already going gray as migraines set it. [b]What is that???

[/b]

Ignoring the obvious, I proceed to set the top-view aright. With another R-rotate about the same point (but wrt the Z-axis), I create hierarchy b[/b]. What we have now is a mess – the bones do not lie on the same plane and each one is ‘rolled’ to a different direction. Should I be worried about this? Coming from a background where bones have to lie on one plane to avoid issues, this is big! A former MAX user would expect to find an untarnished hierarchy plane after the rotation … But, No, blender handles bone transforms differently.

[b](D)[/b] is just same as [b](B)[/b] but with the toe bones locally adjusted.  Yeah, I tried that too.  :hmm: Hmm, I perceive there is a way around this.  Mine is to script a tool that will tidy the roll/head/tail alignments or is this so trivial and unworthy of the expense?  [b] What do you think?[/b]

#11

Don’t do much rigging so could recall wrong, but perhaps try ‘t’ for (bone) twist? :surprised


#12

‘t’ brings out the tool pane. Its Blender 2.5 beta.


#13

For IK chains you can set up limits of rotation for each bone.


#14

Argh, that’s right, as I said, haven’t done this in a while, it’s ctrl+R for ‘set Roll’, just checked. :slight_smile:


#15

Hi
I am expert in Python Programming In Blender.
See this Video
http://www.youtube.com/patriciaumarawal#p/u/16/D3OXElCar-0

Imported Daz 3D TreeFrog Character in Blender alongwith morps
Daz Minic Animaton Created and Mimic Output -> Qt->Keys saved as Text File.
This Text File used in Blender->Python and animated Shape Keys and Mix the sound with Sony Vega.

This complete animatoin is done in Blender.

I have created 4 Leg Walk Cycle also in Blender using Python see this

http://video.google.com/videoplay?docid=-5597448661088555013


#16

There’s a guy on BlenderArtist (Toloban) who has worked through a very similar problem. He used Python to calculate the roll angle of specific bones to drive shape keys (to simulation muscle deformation) with a greater precision. I’m not a Python scripter, but think this thread will help you. He was working with scripting and animation since 2.47. Follow his posts, and I’m sure you’ll run into more info. He had a website breaking down his work in detail. The API in 2.5 looks much different, but I can imagine how his work will be easier now, than it was back then.

http://blenderartists.org/forum/showthread.php?t=70033&highlight=shoulder+deformation+python


#17

Checked the thread and, as expected, links are broken. 2.47 was a long time ago … I didn’t grab much that could be of use to my situation since i couldn’t access the externally linked files. Recalculating the roles with Ctrl+N aligns them to the front view … which is not always desirable. I wrote a tiny script to align the rolls for a hierarchy, with reference to the XY plane and a target bone …So far, its serving me well.


#18

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.