Select Objects by position after rigid body physics in blender 2.9 - blender

I am using the rigid body physics option in blender to drop balls (meshes) into a box. Some of the balls miss the box entirely and fall past the box. I want to be able to select just the balls which fall into the box an export them individually to an .stl file, with their global position (after settling in the box).
I think I know how to export the files, but am having trouble on how to select the mesh objects based on their position at a given frame. I am planning to use this for multiple instances, and hence I need help with a way of doing this via scripting using python.
Note: The balls are dropped from a random height and when I select the object, the z position it shows still looks like its initial starting position.
Im new to blender, so any help is greatly appreciated

I did find this elsewhere, you need to use .matrix_world.translation rather than .location to select objects via their locations at a given frame

Related

Access coordinates of comment boxes on PDF

I have developed a simple but effective tool to automate counting the instances of a specific statement in "sticky note" comment boxes. I'm using this fir marking student exam scripts. Users are using Ctrl+C,Ctrl+C to copy preexisting comments. However in some instances the comments paste directly on top of a preexisting comment. The script counts all but the user has not intended there to be a duplicate.
I'm looking to find a way to access the coordinates of the comment boxes on the PDF so I can check for coordinate duplicates.
Thanks in advance.
coordinates of the comment boxes
All comments are Annotations, and Annotations are required to have a "Rect" entry that defines the coordinates/location of the annotation.
Rect is an array of 4 numbers, defining two opposite corners of the axis aligned bounding box (AABB). The canonical form is to define the bottom left first, and the top right second, but you should just assume it is two opposite corners.

Split colors into layers in photoshop

I have scanned images with alpha channel that I need to compress. The images are drawings. Unfortunately their creation process creates random variation in color that compress poorly in PNG or even cause negative compression.
If I run filters over the data, I wipe out the text.
If I could split out all the pixels that are approximately a specific color into a separate layer, I could run filters without affecting the text.
There are four distinct colors I would like to split out.
The source image is indexed so there are not a lot of variation that needs to be split out.
Is this possible in Photoshop? If so, how?
-=-=-=-
I have not seen the format for a human readable color table. That would make things a lot easier. I have created some within photoshop and it is a PITA.
I was thinking about doing this manually at first then possibly automating it.
I have tried the magic want toll but I cannot get it to distinguish colors well. For example, I have purples and black. To get the thing to select all the purples, it grabs the blacks as well.
You can Scan image with Photoshop File > Import > WIA Support select your printer/Scanner and then scan your picture its come in actual color which you want and then you can compress its not distort your color
The best thing I could come up with was MAGIC WAND and disable the continuous setting.
Cut and Paste Special to a new layer.
I would preferred to select Polygon lasso or Magnetic lasso tool to select specific area.
Otherwise you select the command Select | Color Range and Select color with eyedropper tool
Best way to select all of a certain colour is to go to Select>Color Range
then select white with the eyedropper tool, this way it selects everything with the white value more accurately than manually with he magic tool, it gets all the little things you may miss. then use that to cut/paste into a new layer with ctrl+shift+v to put paste it in place :)

How to measure different coordinates from a PDF file on Windows?

I am looking for a way to measure the coordinates of different rectangles on a PDF file?
Mainly I do have to perform some overprinting on an existing PDF and I need to know the x,y,w,h on where I am supposed to write the texts.
It seems that Preview.app on Mac has this ability but so far I wasn't able to find anything on Windows that does the same.
Please do not confuse this feature with the Measuring Tools from Adobe Reader which are used to measure distance in printed construction stuff, not the PDF page itself.
It seems that the default using of measure is point, so I need something that would allow to select a rectangle and that will tell me the coordinates.
Please do not suggest on exporting as a imagine and using something else to measure the pixels on the image.
Update: http://legacy.activepdf.com/support/knowledgebase/view.cfm?tk=rl&kb=11866 -- PDF Units, that's what I am looking for, something to measure the PDF coordinates in PDF units.
Disclaimer: I work for Atalasoft.
I know you said not to suggest this, but honestly, it's the easiest approach:
If you mean "sweep out a rectangle in the UI and report the coordinates", that's pretty straight forward, but it's going to be a build-your-own type of thing. What you will need are:
A PDF rasterizer (GhostScript, Acrobat, FoxIt, Atalasoft) to get you an image at a specific resolution.
A tool to display that image in a window and let you sweep out a rectangle (this is straight forward winforms type code for .NET, but we have a control that does this out of the box - combining 1 & 2 into one step).
A tool that can look at the structure of a PDF page and report back the crop box (if any) and the media box for each page (iText, DotPdf).
A tool/understanding of matrix transformations to build the matrix that goes from display space into PDF space (and/or vice versa, probably in iText, definitely in DotPdf)
The code flow becomes something like:
For each page:
Open document, pull out crop and media box, rasterize page, build transformation matrix.
Display image, build/hook into event for selection changing.
Push the image viewer rectangle coordinates through the transformation matrix.
Profit.
From a coding point of view (assuming 0 prior knowledge of this, but a decent understanding of linear algebra), from 3 days to a 2 weeks. If I were to write it, it would probably take on the order of a few hours, but I wrote most of our PDF tools and this is pretty easy.
If your goal is to intuit where rectangles are on the page and report back those coordinates, that's also doable, but it decidedly non-trivial in comparison. You need to write code that can rip through a PDF display list and interpret the contents correctly. That means being able to handle all the cumulative matrix transformations, the graphics state changes, the gstate object use, Form XObject placement, and so on. You need to answer the question "what is a rectangle?" because in PDF placement, it could be an re operator, a set of degenerate beziers, a set of lines, an image of a rectangle or (surprise!) a combination of all of the above. Honestly, intuiting anything about the content on a PDF page is a Herculean task.

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...

Finding a word's frame (position and size) on the screen using Cocoa or Carbon

Here's a tough one:
I need to be able to find a word's position and size (its frame) on the screen (its first occurence is enough, from there I should be able to get the next ones).
For example, I would like to be able to detect word positions in (but not limited to) Word, Excel and PowerPoint for Mac, as well as Safari and others.
The solution should be as fast as possible; I should be able to find at least 5-6 words per second and use as little CPU time as possible.
Here's what I thought of so far:
OCR in a window's screenshot / graphics context (any good Open Source framework that works on Mac OS X 10.4 and that can be used in a commercial product?). Evernote is very good at spotting words in images. I don't know if it uses a custom in-house engine or an Open Source / commercial one but that would be the kind of engine I would like to use if this is a "valid" solution. Ideally I would detect the word's frame in the active application's window (how to get the frame of another application?).
Getting some kind of "hook" on Quartz drawing of text and intercepting the location of the word when it's drawn (does not seem very feasible at first glance!).
AppleScript, but it depends a lot on what API the application offers (I don't think you can get a word's coordinates in a Word document from what I've seen) and it's slow.
... out of ideas ...
My goal is to get all the word's frames in a paragraph in the right order based on a string containing the text of the paragraph.
Thanks in advance for any hints!
As a starting place, you may want to take a look at QuickCursor's code. It retrieves text from many different applications through the AX Accessibility APIs. Now, it won't grab the pixel placement of the word, but it will at least return the NSString associated with the text in that UI element. Of course this means that the app in question has to support these APIs; I don't know if the MS Office suite would. In addition, it only supports editable elements, so an un-editable webpage in Safari won't work either. But it may give you a starting point for some ideas.
Take a look at the QCUIElement.{m,h}, and then the implementation in the QCAppDelegate.m (beginQuickCursorEdit:)... the implementation of his abstracted QCUIElement seems to be as simple as:
QCUIElement *focusedElement = [QCUIElement focusedElement];
id value = focusedElement.value;
Edit: Aha! Check out the Accessibility Inspector Sample code: UIElementInspector. It can actually get the AXPosition of elements on a page. Now, it's not word-by-word, but we're getting closer. It'll tell you the x,y placement of a textblock, as well as the words contained in the textblock.
This is possible, but very hard to get working reliably. You can play with Spell Catcher's Direct Connect feature to see an example.