CamBam

Resources => Scripts and Plugins => Topic started by: dh42 on August 09, 2013, 23:29:22 pm

Title: [VB script + plugin] Invert selection
Post by: dh42 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
Title: Re: [VB script] Invert selection
Post by: dh42 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
Title: Re: [VB script] Invert selection
Post by: lloydsp 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
Title: Re: [VB script] Invert selection
Post by: dh42 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
Title: Re: [VB script] Invert selection
Post by: lloydsp on September 10, 2013, 15:23:12 pm
Ah!  So glad I asked!
Lloyd
Title: Re: [VB script] Invert selection
Post by: dh42 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
Title: Re: [VB script + plugin] Invert selection
Post by: dh42 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