# How can we create mechanical relationships between 3D objects?

**URL:** <https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285>\
**Category:** Project Guidance\
**Created:** [December 10, 2019, 6:13am UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285 "2019-12-10T06:13:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![optiq](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@optiq](https://discourse.processing.org/u/optiq)\
**Post date:** [December 10, 2019, 6:13am UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285/1 "2019-12-10T06:13:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [December 10, 2019, 6:44am UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285/2 "2019-12-10T06:44:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![optiq](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@optiq](https://discourse.processing.org/u/optiq)\
**Post date:** [December 10, 2019, 6:41pm UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285/3 "2019-12-10T18:41:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [December 10, 2019, 10:43pm UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285/4 "2019-12-10T22:43:45Z")

</div>

Hello,

Start here:

> **[Welcome to Processing!](https://processing.org/)**
>
> Processing is a flexible software sketchbook and a language for learning how to code. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology…

I found this useful once I was comfortable with Processing:  
[https://natureofcode.com](https://natureofcode.com)

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

[![](https://img.youtube.com/vi/XtMmeAjQTXc/maxresdefault.jpg "Episode 1: Introduction - The Mechanical Universe") ](https://www.youtube.com/watch?v=XtMmeAjQTXc)

See examples available with Processing:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b89556ba9f603290dba134fa39edbeecf1c117d8.png)

This was a project I started with an object file:

> [@Yaw, pitch and roll!](https://discourse.processing.org/t/yaw-pitch-and-roll/13591):
>
> Working on a project: Particle systems were adapted from: [https://processing.org/examples/simpleparticlesystem.html](https://processing.org/examples/simpleparticlesystem.html) Model from here: [http://3dmag.org/en/market/](http://3dmag.org/en/market/) Processing: [https://processing.org/](https://processing.org/)slight_smile

More examples:

> **[OpenProcessing - Creative Coding for the Curious Mind](https://openprocessing.org/)**
>
> OpenProcessing - Creative Coding for the Curious Mind

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:

> **[GLV](https://www.youtube.com/user/etshopstuff/videos)**
>
> Stuff. :)

🙂

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 15, 2019, 12:55am UTC](https://discourse.processing.org/t/how-can-we-create-mechanical-relationships-between-3d-objects/16285/5 "2019-12-15T00:55:35Z")

</div>

> [@optiq](#):
>
> For example say I designed a pair of scissors, how can I add a hinge relationship between the two parts?

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:

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

```auto
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);
}

```

 ![ScissorsAnimation--screenshot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/bccf0371c23ea4cb91982050fa8b4ca02b0b401d.png)

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.
