Elements Selection Inefficiency

There seems to be no real way to select elements of an object without producing a huge overlap. It seems the common method of Element selection is a face loop, which cycles through all faces, even if they've been assigned to an element already. Can anyone confirm this? For example:

for f in obj.faces do
(
polyElementArray = polyOp.getElementsUsingFace obj f
)

Doing anything to that array will result in the cycle of doing the same thing over and over for every face in the array, which does work, but is stupid inefficient.

I came up with an absurd workaround involving the Material By Element modifier, which is way faster, but still ridiculous.

The question is this.... Is there no way to generate a clean Array of faces per elements? Seems like it shouldn't be this hard or need such a crazy work around. There is also no way to "count elements" as fasr as i can tell because they would both need the same mechanism.... which i suppose would be an array of face arrays.

Thoughts?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

No need to loop through all faces.
Try this:

(
	if selection.count == 1 do
	(
		curO = selection[1]
		if classof curO == Editable_Poly do
		(
			pogetNumFaces = polyOp.getNumFaces
			poGetElementsUsingFace = polyOp.getElementsUsingFace
			elementFacesArr = #()
			facesBA = #{1..((pogetNumFaces curO))}
			while not facesBA.isEmpty do
			(
				elementFacesBA = poGetElementsUsingFace curO #((facesBA as array)[1])
				append elementFacesArr elementFacesBA
				facesBA -= elementFacesBA
			)
			print elementFacesArr
		)
	)
)
biglittlepictures's picture

Perfect Thanks!

Interesting. Thanks for taking the time to reply! I was able to implement this after taking the time to understand it. There are some brilliant little tricks with code.. it's just a matter of knowing they exist.

Cheers!

-Joel Eckert
Owner, Big Little Pictures

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.