martindb / mpcnc_posts_processor

MPCNC posts processor for Fusion 360 and Marlin
MIT License
63 stars 84 forks source link

Add support for WorkPlane Rotations when using Component Patterns #8

Closed simpsojp closed 3 years ago

simpsojp commented 3 years ago

While using Component Patterns to CNC multiple and identical parts, if parts are not rotated in the same orientation, the MPCNC Post Processor will calculate incorrect coordinates due to Fusion's handling of the WorkPlane vector. Adding the following lines to the "onSection" function produces the correct coordinates in my specific instance: Two simple 2D parts, with the second part rotated 180°. Coordinates are also correctly calculated with the second part rotated 90°

Reference: https://forums.autodesk.com/t5/fusion-360-manufacture/component-pattern-in-2d-cutting-wrong-setting-or-bug/m-p/9268590#M74592

function onSection() {

  var remaining = currentSection.workPlane;
  if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) {
    error(localize("Tool orientation is not supported."));
    return;
  }
  setRotation(remaining);

Note: I have not checked or tested how this possibly impacts patterned 3D parts.

...Apologies if this pull request isn't properly formatted or documented - it's my first.