De-selecting connected polys

Discussions concerning programming of SOFTIMAGE©
bergj
Posts: 36
Joined: 06 May 2012, 03:58

De-selecting connected polys

Post by bergj » 11 Jun 2012, 04:04

Hypothetically, I'm modelling something and it has a lot of selected faces on it that are disconnected. I would want to quickly deselect one of the connected poly "islands" without manually having to deselect each one.

So, in script I would invoke PickElement, select 1 or 2(?) polys, save the selected in a list and get everything connected to them and deselect them. This is where the problem lies, I dont know any commands that can do this for rows and "islands". :-??

My real models can be large and it can take a long time to de-select loops manually if i cant/dont want to undo. I've been working on this for a few days, looked at and tried a lot of code but im not getting anywhere at this point.

Thanks.

Image

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: De-selecting connected polys

Post by rray » 11 Jun 2012, 07:39

One way to deselect a selection island is: invert the whole polygon selection, then use rctools fill command, and then invert the whole selection again.

I'll update rctool to include a "deselect" fill function (Fill->MMB).
softimage resources section updated Sep 26th 2026

bergj
Posts: 36
Joined: 06 May 2012, 03:58

Re: De-selecting connected polys

Post by bergj » 11 Jun 2012, 17:38

Thanks for the tip!

Here I used part of Fill-keep, converted to python, and skipped the invert.

Edit: after using it some more I can see that this serves as a toggle between fillKeep and deselectPoly depending on if you choose a selected or deselected poly. Cool.

Code: Select all

#Deselect Face Loop
####
xsi = Application

obj = xsi.Selection(0)
xsi.SetSelFilter("Polygon")	
bSubSelAvailable = 0
if xsi.Selection.Count:
	bSubSelAvailable = 1
	subsel = xsi.Selection(0).FullName
	
neighborsList = []
pick = xsi.PickElement("polygon", "Select a poly", "End")	
picked = pick.Value("PickedElement")

if bSubSelAvailable:
	op = xsi.ApplyTopoOp("DisconnectComponent", subsel)

for i in picked.SubComponent.ComponentCollection.NeighborPolygons(99999999):
	neighborsList.append(i.SubComponent)

if bSubSelAvailable:
	xsi.DeleteObj(op)
	xsi.ToggleSelection(picked.SubComponent.ComponentCollection.SubComponent, "", True)
	for i in neighborsList:
		xsi.ToggleSelection(i, "", True)