Desk Toy Ready To Go

PP0001 is our first Creo 7 based 3D assembly which is going to be built as a physical prototype. It’s been a great exercise in learning Creo, and just simple mechanical engineering. We will have the parts 3D printed via Catalyst Services out of ABS and Nylon. Several reamers have been ordered from McMaster Carr to hopefully achieve a press fit and a slip fit for the steel pins.

Here are the final renders.

Creo 7: All from a sketch

One of the harder things in designing machines is figuring out how all of the parts interface with each other precisely. In Creo 7 Parametric, the ability exists to draw a series of master sketches which describe how parts interface, then extrude new bodies from these sketches, then create new parts from the bodies, and finally assemble them.

In this case we wanted to make sure that the follower, despite it’s curved shape, moved perpendicular to the surface of the wheel. We created a series of 4 sketches using many construction lines (which don’t show up after you exit sketching mode). These sketches described the key interface and clearance parts of the mechanism, including the maximum and minimum location of the follower as it rides over the highs and lows of the cam wheel. Using this geometry, we could accurately place the tension spring to put a calculated amount of force between the two parts, while ensuring that there was no part interference.

Additional sketches were then created referencing this base geometry to put the finer details on the actual parts to be extruded. They were then extruded, carefully being sure to mark them each as new bodies. Notice even the pin itself was sketched here because all of the pin holes and the pin itself might as well reference the same size circle.

Each body was then saved to it’s own part:

And finishing touches were placed on each part in it’s own file. It’s important not to clutter up the base part too much, but rather keep it focused on overall shapes to the degree needed to ensure everything fits.

Finally all parts were assembled into an assembly, and further revisions were made to the base sketches to improve overall look, size, and function.

Creo 7 Parametric Assemblies

Creo 7 Parametric Assemblies

A point of confusion when learning Creo 7 (coming from Fusion 360 and previously SolidWorks) was how to mate parts in an assembly. Like many things, once you know it’s pretty simple!

It is at the point you are inserting the part into the assembly that you are able to specify constraints/mates.

You can reopen this area of the application by clicking on a part and then then clicking Edit Definition.

Equations in PTC Creo 7

Equations in PTC Creo 7

Today I learned that Creo Parametric has first class support for equations which can be turned into sketch items, and the incorporated into a model. In this example I created a sine wave.

y = sin(x*2) * 100

And told Creo to extend it from x=0 to x=900. Here is a picture of editing the equation.

Once I had that curve defined, I created a sketch on the same plane, and then used the “Project” tool to project the sinewave into the current sketch. After adding sides and a bottom, I had a closed shape.

From there it was a simple matter to extrude, offset, cut, and add some colors.

Python + OpenSCAD

I’ve been interested in automating the process of designing building structures according to a set of input parameters, and having a software application determine all of the pieces necessary to meet structural engineering principals and applicable building codes.

An ideal tool for this is OpenSCAD, which is a 3D modeling program that uses code as input.

There is a nice Python library which is a wrapper around the OpenSCAD input language: https://github.com/SolidCode/SolidPython

Here is a proof of concept. It’s working well so far!

Auto Resize IFRAME Cross Origin

Browser security policies prevent frames from interacting with each other if they are not from the same origin (like domain but even more specific).

However, frames can pass messages to each other.   Here is how you can implement cross-origin iframe auto-resizing based on window.postMessage.

Lets assume we have a parent page that looks like this:

<html>
  <head>
    <title>Parent Page</title>
  </head>
  <body>
     ...
     [iframe id="frame1" src="https://otherdomain.com/frame1.html"]
  </body>
</html>

(assume [] is <> above, sorry about over protective content escaping in wordpress.com)

To enable auto-resizing on this page, add some script to the end of the <head></head> section (or just before </body> if that is where you put them).

This listens for a “message” event and will check to see if it has an action of “resize”.  If so it will update the specified id’s height.

<script>
  window.addEventListener("message",function(e){
    if(e.data.action=='resize') {
      document.getElementById(e.data.id).style.height = e.data.height+'px';
    }
  },
  false
  );
</script>

On the embedded frame source, you need an onload event to send a message:

window.onload = function() { 
  window.parent.postMessage({action:'resize',id:'frame1',height:document.body.scrollHeight+20},'*');
};

Note that we need to pass “frame1” which is the ID of the frame on the parent page.

Then the frames should auto-size to their content.

[ERROR] InnoDB: Cannot add field in table because after adding it, the row size is 8572 which is greater than maximum allowed size (8126) for a record on index leaf page.

One day, suddenly, we couldn’t reload a production backup.  Oh no!  It took a bit of digging around but here is the issue, should you find yourself running into it:

Using the InnoDB COMPACT ROW_FORMAT, there are some rules InnoDB uses to decide how much data to put on the first page and how much to put on overflow pages.  While VARCHAR and TEXT type columns are typically stored on overflow pages with no problem, when using the COMPACT row format, up to the first 767 bytes of each field will be stored on the primary page.

This error happens when the amount of actual data exceeds the allows limit for a row size on the main page, which is about 50% of the innodb_page_size variable.

https://mariadb.com/kb/en/library/innodb-compact-row-format/

If you have a circumstance with say, 11 TEXT or VARCHAR fields, each with at least 767 bytes of data, and running an innodb_page_size of 16k (which results in 8126 being max row size on main page) …… then 767*11=8437 stored on main page is greater than 8126 which is the “maximum allowed size for a record on index leaf page”, and you will get this error.

The solution is to investigate the use of either DYNAMIC or COMPRESSED row format, depending on your application.