LDCad Selecte same height


RE: Selecte same height
#4
(2022-03-24, 6:09)Jaco van der Molen Wrote: is someone willing to code this script?

I am. Smile  Quick-and-dirty without rounding or user-interaction. Just selecting all parts with the same Y value as the exactly one selected part.

Code:
function select_same_y()
  local ses=ldc.session()
  if not ses:isLinked() then
    ldc.dialog.runMessage('No active model.')
    return
  end

  local sel=ses:getSelection()
  local cnt=sel:getRefCount()

  if cnt~=1 then
    ldc.dialog.runMessage('Exactly one item should be selected.')
    return
  end
 
  local y=sel:getRef(1):getPos():getY()
 
  local sf=ldc.subfile()
  local refCnt=sf:getRefCount()
  for i=1,refCnt do
    local ref=sf:getRef(i)
    local pos=ref:getPos()
    if (pos:getY()==y) then
      sel:add(ref)
    end
  end
end

function register()
  local macro=ldc.macro('SelectSameY')
  macro:setHint('Select all parts with same Y value.')
  macro:setEvent('run', 'select_same_y')
end

register()
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Selecte same height - by Jaco van der Molen - 2022-03-23, 6:45
RE: Selecte same height - by Roland Melkert - 2022-03-23, 19:15
RE: Selecte same height - by Stefan Frenz - 2022-03-24, 15:19

Forum Jump:


Users browsing this thread: 4 Guest(s)