Hi Pilou, or this variation will work as a toggle, if you use the same shortcut a second time it should reset it:
script: /* Set cplane to selected face or reset on second use */ var faces = moi.geometryDatabase.getSelectedObjects().getFaces(); var was_set = false; if ( faces.length == 1 ) { var f = faces.item(0); var cp = moi.view.getCPlane(); var vm = moi.vectorMath; if ( f.isPlanar ) { var p = f.planarFrame; if ( !(vm.pointsAreEqual(p.origin,cp.origin) && vm.pointsAreEqual(p.xaxis,cp.xaxis) && vm.pointsAreEqual(p.yaxis,cp.yaxis)) ) { moi.view.setCPlane( p ); was_set = true; } } } if ( !was_set ) moi.view.resetCPlane();
- Michael
|