LDCad Selecte same height


Selecte same height
#1
Hi all,

In LDCad it is possible to select a part and then select same part, same part and color, same color, same step...

But now I am looking for a way to select all parts that are at the same height, i.e. y-coordinate.

@Roland: I'd like to suggest that for a next version?

For now: can this be done with a script?

Thanks!

Jaco
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: Selecte same height
#2
(2022-03-23, 6:45)Jaco van der Molen Wrote: For now: can this be done with a script?

This can be done in script.

You can get the Y value from the current selection.

Then loop trough all parts adding the ones with the same Y coordinate.
Reply
RE: Selecte same height
#3
(2022-03-23, 19:15)Roland Melkert Wrote: This can be done in script.

You can get the Y value from the current selection.

Then loop trough all parts adding the ones with the same Y coordinate.

I thought as much. Alas, I have no clue how to make such a script.
So either can someone point me in the right direction or is someone willing to code this script?
Much apprieciated!
Jaco van der Molen
lpub.binarybricks.nl
Reply
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
RE: Selecte same height
#5
(2022-03-24, 15:19)Stefan Frenz Wrote: 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.

Thank you, this is exactly what I need for now with the model I am working on.
Jaco van der Molen
lpub.binarybricks.nl
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)