(2020-05-05, 22:07)Roland Melkert Wrote: I realized if you assume all selection points are on a plane, you can drop the setX/setY lines and calculate the plane normal instead of using a static x vector
Code:function onRun() local sel=ldc.selection() if sel:getRefCount()<3 then return end local a=sel:getRef(1):getPos() local b=sel:getRef(2):getPos() local c=sel:getRef(3):getPos() local ba=a-b local bc=c-b local n=bc:getCross(ba) n:normalize() local bb1=n:getSignedAngle(ba, bc) local bb2=math.deg(math.acos(bc:getLength()/ba:getLength())) local angle=-(bb1-bb2) ldc.setClipboardText(angle) ldc.dialog.runMessage(angle) end
neg y makes it somewhat confusing but i think this should work in any orientation, not tested though.
This version got me close, but not quite: