Operate on data or simulate user input? - blender

I'm trying to write my first blender script to import a BVH animation and copy the keyframes from the imported rig to an existing rig. It seems to me there are two ways to do this:
Operate on the data directly, by looping over bpy.data.objects[rig].animation_data.action.fcurves.keyframes and somehow copying them into the corresponding data structure on the existing rig
Simulate the way a user would do it by setting the context to a 3D view, importing the mesh, setting the context to the curves editor, selecting all, copying, switching back to 3D view, selecting the existing rig, switching back to curves again and pasting the data
Number 1 sounds like the right way to me, but looking at the API it seems that it's more geared towards number 2. Is that right? The Blender way of doing things would be to set the selection and use the copy/paste operators?
I'd like to know which is the idiomatic way of doing things in Blender.

Related

Write to left and right display

I have a Lily58 Pro, this is a split keyboard with two displays. I am looking for a way to display text and images on both displays.
To create my custom firmware I have done the following:
Copy default Lily58 firmware
Alter the layers in keymap.c file.
As far as I understand I need to alter the oled_task_user() method to write to the secondary (right hand side) display. The QMK Documentation provides some kind of example but I don't understand it.
Should I be importing something from the split_commom package?
Question
How do I display text/image on the secondary display? A small example would be much appreciated.

Image recolour in Excel

I have a greyscale image with some transparent sections too. I would like to recolour this within excel (based on the value that a user types in a cell or something)
Manually, all I need to do is select the picture then in the ribbon 🡒 format 🡒 colour 🡒 more variations 🡒 more colours and select appropriately. I've tried the macro recorder on these steps but get nothing useful.
Searching the web has led me to believe that the Shape.PictureFormat.Recolor method, which I'm guessing is what I want, is only availible in Publisher. I'd rather not interface with thatfor portability reasons (in case publisher isn't installed), and I'd also like this to run as speedily as possible.
I've even considered converting the image to an array of bytes, performing the required pixel manipulations then converting back to an image, but I think that'll be slow. I also don't have a clue how.
Is there a method in VBA to recolour an image in this way, leaving alpha as it is? Perhaps with the use of an ActiveX image control? Here's an example image in case it's not clear
White 🡒 Green
Black 🡒 Black
Alpha 🡒 Alpha
If you can't find a pure object model based solution, you can try to modify the document xml. It is not the easiest of solutions, but it is far easier than pixel manipulation.
Do like this:
Save your workbook without modification
Do the color change
Save the file again, with a different file name
Unzip the two *.xlsx files you created
Analyze the differences. You'll most likely find it in the drawings folder
Recreate the changes in the xml of the second file in the first one and zip it back together. If that works, you now have a theoretical way to the solution.
If you get this to work, you can automate these steps.

.bvh set parent with automatic weights issue

I'm working on a blender project trying to import the the bvh and map it to mesh. As shown in the below figure I've been able to import the mesh and then imported the .bvh file. The first question is, under the .bvh file in the menu on the top right as shown in the below figures, there are two files under the object, one is named as the same name of the .bvh file and the other is named Pose. When I click on the 01_01 even after fitting the human on top of it this is what happens:
so as seen the armature and the human are separated.
And when I choose the pose one this is what happens:
so anyway, after that I select the human mesh then shift the armature and then click ctrl+p and choose parent with automatic weights but this is the result:
I have no idea why this is happening? I'd be very thankful if anyone could please advise how to fix this. Because if I played the file after this is the a snapshot of the result:
Your problem is that all the vertices are not being assigned to the armature when you reparent the mesh.
Either you need to go into edit mode and manually assign the remaining vertices to there proper groups or...
...if the bvh armature has the same amount of bones as the makehuman armature does, then try scaling the bvh armature up to the size of the makehuman armature. Then go and add Copy Location/Rotation/Scale constraints to each of the bones to have it copy the same bone on the other armature.
Iv'e done it before and it works. Just takes awhile tho.

Photoshop jsx image grid

What I am ultimately trying to do is to create a grid of images for print that are minor variations of the same thing (different text is all). Looking through online resources I was able to create a script that changes the text and exports all of the images necessary (several hundred). What I am trying to do now is to import all of these images into a new photoshop document and lay them all out in a grid and I can't seem to find any examples of this.
Can anyone point me in the right direction to place a file at a specific coordinate (I'm using CS5 and have the design suite so if there is a way in illustrator to do this quickly...)?
Also, I'm open to other ideas on how to do this (even other programs) easily. It's for labels so the positioning on the sheet has to be pretty precise...
The art layer object has a translate() method that takes delta x and y params. You'll need to open each image, copy it to the target document, get its current location (using artLayer.bounds) and do the math to find the deltas to position it where you want it. Your deltas can be in pixels so you'll get plenty of precision.
Check out your 'JavaScript Scripting Reference' pdf in your Adobe install directory for more details.
Ok I'm marking Anna's response as the answer because though I didn't fully test it, it seems like it should work and answers the original question with jsx. However I'm also leaving my final solution in case anyone else runs across this with the same issue and may prefer this method as well.
What I ended up doing instead is using InDesign. I figured out that it has a grid option that lets you import a number of files and place them all in an equal grid in a single command. This is almost exactly what I was looking for, except that it leaves a small border/margin in between the columns and grids and mine were designed to meet exactly.
I couldn't figure out how to make it not have the border (I have very little experience with InDesign, it may be possible). However I was able to select all my images and scale them uniformly to be the correct size, then I just selected each column and dragged it over to snap to the adjacent column and the same with rows...

Is it possible to reference a photoshop file or layer comp from within another photoshop file?

Creating all the art for a large website often involves a couple dozen 50+mb photoshop files. Frequently, a given module may appear in more than one file.
Is there a way to reference an oft-used module from another file?
For instance -
"site-section-2.psd" references "common-module-h.psd", and "site-section-6.psd" also references "common-module-h.psd", so that any time updates are made to "common-module-h.psd", the updates appear in both files which reference it.
Possible?
(maybe with photoshop javascript?)
I've checked the JSX Photoshop Object Model, and you can access LayerComps, but there is no magic function to save from one file to another. Something like this could be written to disk, from file1.psd for example, then loaded into file2.psd.
It's a bit of a long shot and I don't know if it's worth the trouble.
For web prototyping I use Fireworks and and I'm pretty happy. You can easily create symbols (much like in Flash and Illustrator) and even save them to a Common Library, which means it will be easy peasy to keep your navigation items for example up to date, for all the files using it. You can even import PSD files into Fireworks, only not all the filters will be supported.
Don't know if you can keep most of the eye-candy in Photoshop and then assemble reamble versions with ease using Fireworks.
You can try converting all the layers into one smart object and then drag the smart object layer into the new .psd file.
Go to the Layers palette: Window > Layers(F7).
LMB SINGLE CLICK the top layer.
Scroll down Layer palette until you get to the bottom.
SHIFT + LMB SINGLE CLICK. At this point all the layers should be hilighted.
RMB SINGLE CLICK any of Layer "Titles".
You should see a menu pop up so use the mouse to scroll until you find "Convert to Smart Object". LMB SINGLE CLICK to convert all the layers into one smart object. The smart object can be edited by double clicking it in the Layers palette. You can also drag a smart object from one .PSD into another .PSD. I usually just open both .PSD files and drag the smart object form one Layers palette to the other Layers palette.