Windows A request for a simple script of ldcad


A request for a simple script of ldcad
#1
I hope to add a Lua script to detect and delete parts of duplicate coordinate axes
Sometimes I accidentally put in overlapping parts and it’s hard to find them. 
I think this should be easy to implement, such as detecting the same XYZ coordinates in the file and deleting them, but I don't know much about Lua.
hope someone can help me solve it.thk
Reply
RE: A request for a simple script of ldcad
#2
(2024-12-14, 9:18)HWQ Wrote: I hope to add a Lua script to detect and delete parts of duplicate coordinate axes
Sometimes I accidentally put in overlapping parts and it’s hard to find them. 
I think this should be easy to implement, such as detecting the same XYZ coordinates in the file and deleting them, but I don't know much about Lua.
hope someone can help me solve it.thk

This should be fairly easy, I'll try to write a quick and dirty one later this week or in the weekend.
Reply
RE: A request for a simple script of ldcad
#3
Big GrinBig Grin Big Grin waiting for u .thks Heart
(2024-12-17, 22:43)Roland Melkert Wrote: This should be fairly easy, I'll try to write a quick and dirty one later this week or in the weekend.
Reply
RE: A request for a simple script of ldcad
#4
(2024-12-23, 3:45)HWQ Wrote: Big GrinBig Grin Big Grin waiting for u .thks Heart

sorry, something has gotten in the way. I probably won't be able to work at anything ldraw related for at least a week Angry
Reply
RE: A request for a simple script of ldcad
#5
(2024-12-23, 21:03)Roland Melkert Wrote: sorry, something has gotten in the way. I probably won't be able to work at anything ldraw related for at least a week Angry
OHHHHHHHHH NO.
I hope you'll finish your work as soon as possible and help me handle this small request. Blush
Reply
RE: A request for a simple script of ldcad
#6
(2024-12-23, 21:03)Roland Melkert Wrote: sorry, something has gotten in the way. I probably won't be able to work at anything ldraw related for at least a week Angry

Hello, can you help me with this request? It's too troublesome for me to check the overlap one by one. Sad
Reply
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 »



Forum Jump:


Users browsing this thread: 3 Guest(s)