Windows A request for a simple script of ldcad


RE: A request for a simple script of ldcad
#7
Made a quick and dirty one:

Code:
function isUique(lst, needle)

  for key, item in pairs(lst) do
    if needle.name==item.name and (needle.pos-item.pos):getLength()<0.1 then
      return false
    end
  end

  return true
end

function onRun()

  local sf=ldc.subfile()
  local sel=ldc.selection()
  local lst={}
  
  sel:remove()

  for i=1,sf:getRefCount() do
    local ref=sf:getRef(i)
    local info={pos=ref:getPos(), name=ref:getName()}

    if isUique(lst, info) then
      table.insert(lst,info)
    else
      sel:add(ref)
    end
  end

end

function register()

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

register()

Save it to a .lua file and place it in LDCad/scripts/default/global to use it.

It will find identical parts at (nearly,<0.1 ldu) the same place ignoring color and rotation.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: A request for a simple script of ldcad - by Roland Melkert - 2025-01-03, 6:59

Forum Jump:


Users browsing this thread: 1 Guest(s)