How can we create mechanical relationships between 3D objects?

I do all my engineering design in Solidworks and would like to feature models with moving parts. For example say I designed a pair of scissors, how can I add a hinge relationship between the two parts? Can I do this by exporting the whole assembly file as an .obj file or would I need to export each part and constrain them some type of way from there? I can’t seem to find anything showing me things that can accomplish this but from what I’ve been learning so far I’m sure there has to be a way to do it. Can anyone help shed light on how to go about doing this?

I will first check if you can do this in SolidWorks first.

If you want to try Processing and if you are able to export an object as .obj, then you can try to load it in Processing. I know in solidworks you can define your reference frame and reference planes and choosing the right reference plane would setup your pivot points. However, this will not be of any use (?) in Processing as Processing does not support this type of files as defined by SolidWorks. If you are able to load an object in Processing, I imagine you will need to use translate/rotate operations to place your object and to move your object.

Keep in mind I am thinking loud here as I have never attempted this myself, that is, loading shapes and models directly from SolidWorks. Try your luck by checking previous posts.

Kf

We can export .obj files from Solidworks, we can export an entire assembly file as an .obj, or we can export each part individually as an .obj.

Hello,

Start here:

I found this useful once I was comfortable with Processing:
https://natureofcode.com

This inspired me when I was younger (and still does!) and available now for everyone:

See examples available with Processing:

This was a project I started with an object file:

More examples:

Work through examples and start thinking about what you can do with the palette of tools that Processing offers!

Its math, programming, inspiration, and creativity combined.
A worthy pursuit.

Some “rough cuts” of projects I posted on YouTube:

:slight_smile:

In Processing, whether in 2D or 3D, using simple geometry or PShape or meshes, the easiest way to articular multiple parts in terms of rotation (like a scissor hinge, or a gear) is to draw them centered on the rotation point.

for example, here is half a scissor:

void drawScissor(float w, float h) {
  triangle(-100*w, -20*h, 200*w, -10*h, -100*w, 25*h);
  ellipse(-100*w, 10*h, 100*w, 60*h);
  ellipse(0, 0, 20*w, 20*h);
}

Because it is centered on the joint at 0,0, you can composite them and rotate them, and they will align and articulate correctly.

void setup() {
  size(400, 400);
}
void draw() {
  background(128);
  translate(width/2, height/2);
  float rot = sin(frameCount/120.0);
  rotate(rot);
  drawScissor(1, 1);
  rotate(2*-rot);
  drawScissor(1, -1);  
}
void drawScissor(float w, float h) {
  triangle(-100*w, -20*h, 200*w, -10*h, -100*w, 25*h);
  ellipse(-100*w, 10*h, 100*w, 60*h);
  ellipse(0, 0, 20*w, 20*h);
}

Another general-purpose approach is to use a physics library with articulation points – in 2D, a common one is Box2D for Processing. In 3D I’m not sure – possibly PixelFlow, which I believe has 3D softbody physics.

3 Likes