Author Topic: [VB script + plugin] Invert selection  (Read 5531 times)

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6680
    • View Profile
    • Cambam V1.0 French Doc
[VB script + plugin] Invert selection
« on: August 09, 2013, 23:29:22 pm »
Hello,

Here is a script to invert the selected shapes.

++
David

Code: [Select]
'invert selection - dh42 2013

sub main

dim ent as Entity
dim ID as integer
dim rep as boolean = false

        CamBamConfig.Defaults.ReloadTreeAfterScript = false

' store data for actual selection
dim oldselection as ArrayList = new ArrayList()

for each ent in view.SelectedEntities

oldselection.Add(ent)

next ent


'select all
view.SelectAllVisibleGeometry()

dim invertselect as ArrayList = new ArrayList()

'scan all the objects
for each ent in view.SelectedEntities

rep = scanID(ent.ID, oldselection) ' test if ID exist in old selection

if rep = false then 'not found
invertselect.Add(ent) ' add the object to the new list
end if

next ent

view.Select(invertselect)

end sub

'--------------------------------------------------------------------

function scanID( ID as integer, oldsel as ArrayList ) as boolean

'scan the old selection, if ID match, return true, else false

dim ent as Entity

for each ent in oldsel

if ID = ent.ID then 'match found
return true
exit function
end if

next ent

return false 'no match found

end function
« Last Edit: January 02, 2014, 20:21:38 pm by dh42 »

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6680
    • View Profile
    • Cambam V1.0 French Doc
Re: [VB script] Invert selection
« Reply #1 on: September 10, 2013, 13:00:11 pm »
Hello,

A little correction to the script, because the objects are selected in the view but not in the tree.

(4 th line in the main sub)

CamBamConfig.Defaults.ReloadTreeAfterScript = false

++
David

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8541
    • View Profile
Re: [VB script] Invert selection
« Reply #2 on: September 10, 2013, 13:48:16 pm »
Um... wouldn't you want to make that '=true', so the tree selection occurs after the script?

Or does that refresh the whole tree to the unselected state?

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6680
    • View Profile
    • Cambam V1.0 French Doc
Re: [VB script] Invert selection
« Reply #3 on: September 10, 2013, 14:21:49 pm »
Um... wouldn't you want to make that '=true', so the tree selection occurs after the script?

Or does that refresh the whole tree to the unselected state?

Lloyd


Hello,

Explanation from our Jedi master here  ;)

http://www.cambam.co.uk/forum/index.php?topic=1972.msg11881#msg11881

Note that without this line of code, the objects are selected, we can move it, but if you try to delete or cut it, nothing happens.

++
David

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8541
    • View Profile
Re: [VB script] Invert selection
« Reply #4 on: September 10, 2013, 15:23:12 pm »
Ah!  So glad I asked!
Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6680
    • View Profile
    • Cambam V1.0 French Doc
Re: [VB script] Invert selection
« Reply #5 on: January 02, 2014, 19:40:38 pm »
Hello,

And the new version as plugin.

The new item is located in the Edit menu and has a shortcut -> Ctrl I

Enjoy
++
David
« Last Edit: February 07, 2014, 16:55:29 pm by dh42 »

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6680
    • View Profile
    • Cambam V1.0 French Doc
Re: [VB script + plugin] Invert selection
« Reply #6 on: February 07, 2014, 16:57:23 pm »
Hello,

A little change, I just see that the Ctrl + I is already used for 'convert to region'  :-[

The new version use now Shift+Ctrl+I

++
David