Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Part naming/ID after breaking a part into three pieces

I'm working on a piano-related project. I've modeled all the keys and combined them into a single part by extruding a long block to connect them to each other. I'm then trying to select a particular key based on a variable. I translate the block of keys so that the desired key is aligned to a sketch, then extrude from the sketch to delete part of the bit that connects all the keys. This leaves me with three pieces — the desired key, a block of higher keys, and a block of lower keys. Then I want to delete the two blocks of keys, leaving me with the one I was trying to isolate.
I would think that the three parts that are left after the cut would be the same, regardless of which key I was cutting out. The problem is that they change depending on which key I'm cutting. As a result, when I set it to correctly delete the two blocks of keys for one setting, changing the variable to cut out a different key leaves behind one of the blocks, not the desired key. The three parts after the cut have switched around.
To simplify: Is there a way to make sure that when I cut part 1, the resulting part on the left is now part 1 and the one on the right is part 2?
The first 3 screenshots below show the process working correctly. The second three show the process working incorrectly. The only thing I've changed is the initial translation of the block of keys.
Comments
could you make your document public and share a link here? that will help in better understanding your way of working and figuring out a solution.
perhaps this would work
transform→copy in place the whole keyboard (maybe even twice if you want 3 parts) (this is the most reliable way of knowing what is the original part you may want to keep.
extrude intersect with the original part to provide the key cap
extrude intersect or cut with the copied part (or cut away stuff)
I'm not sure if the "assign identity" FS would help here (https://cad.onshape.com/documents/fcf31e8bc171b06037008400/v/7e1b5b2304e2bd6d9223a41a/e/e076332e1669ea9babcaf65b)… maybe worth a shot.
However I have to ask why you are combining into a single part and later trying to extract a single key from that… This seems like a strange workflow and I suspect there might be a better way of doing what you are trying to achieve but it's hard to tell without knowing what you are trying to do…
Re what I'm trying to do: I want to be able to set a variable to decide which key the project produces.. Basically, I want to make the whole thingprocedural in the sense of "I want to 3d print C#4. Okay, I'll enter the corresponding number into the variables, Onshape re-calculates, and boom, I'm left with C#4. The idea is that I want to produce one note at a time, not all at once. It's for the sake of the development process, where I'm usually printing just one note at a time so I can test tuning, etc.
Here's the document:
https://cad.onshape.com/documents/790c4e18b1027ef7711e74a9/w/513f21d89a57b1cb3bda140b/e/2cb2900842c87058046c0598
Here's the document: https://cad.onshape.com/documents/790c4e18b1027ef7711e74a9/w/513f21d89a57b1cb3bda140b/e/2cb2900842c87058046c0598
To make a different key/note, modify #key_index. It works in its current value (2) but some other values don't (e.g. 8).
Sorry for my late response. I appreciate that you responded to my question.
@david_hernston
It appears there are only 4 different keys on a piano (Left key, middle key, right key, black key) maximum. I can't see how your approach makes sense under this condition. Rather than to swim against the currents, you might just ride the wave.
Why not create one black key model and then a white key model with 3 switchable configurations? Arrange these in an assembly and you can make about any keyboard possible just by configuring which type is needed in whatever position.
Why my approach makes sense:
First, the keys on a piano aren't evenly spaced. Yes, all the white keys have the same width at their tip, but the spacing and width of the black keys are different between the triple and the double sets of blacks. You'd never know without looking up the standard dimensions of a piano keyboard, but all seven white keys in the scale are slightly different shapes to accommodate the spacing of the black ones.
Second, while the actual keys are not evenly spaced, the sound-producing mechanisms they're connected to are. As a result, the connection to the mechanism on the bottom of the key has to be positioned differently for each key. When I print the keys, they will have a label saying which note they belong to so I can more easily match the correct key to its corresponding mechanism without screwing up the spacing.
Re the "assign identity" FS:
I'm afraid I don't know what this does or how to use it….