Thinking about doing a LDCad 1.7 version


RE: Thinking about doing a LDCad 1.7 version
(2020-05-05, 20:54)Roland Melkert Wrote: It's a fairly simple one if you assume it's on the abs yz plane

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()

  a:setX(0)
  b:setX(0)
  c:setX(0)
  c:setY(b:getY())

  local ab=a:getLength(b)
  local bc=b:getLength(c)

  local bb1=ldc.vector(1,0,0):getSignedAngle(a-b, c-b)
  local bb2=math.deg(math.acos(bc/ab))

  local angle=-(bb1-bb2)
  ldc.setClipboardText(angle)

  ldc.dialog.runMessage(angle)
end

function register()

  local macro=ldc.macro('My macro')
  macro:setEvent('run', 'onRun')
end

register()

Could use some more cleanups and dummy proof checks though

It gave me the idea to add access to the relative grid in 1.7, so thanks for that

See, now that I see it written out, it makes perfect sense. :-)

This did indeed work, once I a) rotated the model into the YZ plane, and b) replaced the group I was rotating with a submodel (because the script is looking for refs).
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: Thinking about doing a LDCad 1.7 version - by N. W. Perry - 2020-05-06, 3:02

Forum Jump:


Users browsing this thread: 4 Guest(s)