Notifications
Clear all

[Closed] How to Shrink poly array without selecting

I’ve been thinking about adding a feature to a tool I’ve been working on and in order to do so I need to rapidly shrink an array of edges / polies / verts. I know, of course you can do this with a look up of connecting elements using something like polyop.getfacesusingedge but to do this on the amount of polies I’m working on with all the loops and finditem’s would be too slow. Growing is far easier than this so I thought there might be some trick I just can’t figure out in my head for this. Does anyone have any suggestions?

9 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

why do you not want to select subobjects? you can store current selection before and restore it after shrink. it has to be faster than using of polyop conversion methods.
but to do shrink without selection is:
#initial bitarray: (A)
#grow initial: (A+)
#get difference between grown and initial: (A+) – (A) = (B)
#grow difference: (B+)
#subtract grown difference from initial: (A) – (B+) = ©
that gives you shrink

That’s the method I had in hand already. I kept on trying to think of something faster and for some reason I thought there must be something there. I don’t want to use selection methods because anything involving the mod panel tends to be a lot slower than polyop’s, at least in my experience. Thanks for the comment though.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

you told:” I’m working on with all the loops and finditem’s would be too slow. “
my algorithm doesn’t have any loops or finditems… why do you think it might be slow? what is fast enough for you?

I don’t want to use selection methods because anything involving the mod panel tends to be a lot slower than polyop’s, at least in my experience. Thanks for the comment though.

i might be wrong and i don’t have max right now to check, but
[left][size=-0][size=2][font=Courier New][size=2]<void><EditablePoly>.ShrinkSelection selLevel:<enum>
[/size][/font][/size][/size]
[/left]
[left]should work without opened the modifier panel[size=-0][size=2][font=Courier New][size=2]
[/size][/font][/size][/size]
[/left]

(@denist)
Joined: 11 months ago

Posts: 0

i was right.
<poly>.editablepoly.shrinkselection sellevel:<level> doesn’t need the mod panel being open

My get difference function uses a loop and finditem. Maybe it’s a little bit backward?

fn GetUnSharedItems ArrayOne ArrayTwo = 
 	(
 		answer = #()
 		for i = 1 to ArrayOne.count do (if (finditem ArrayTwo ArrayOne[i]) == 0 then (append answer ArrayOne[i]))
 		answer
 	)
2 Replies
(@panayot)
Joined: 11 months ago

Posts: 0

Hm, Denis talk above for BitArray, not for Array. (no loops and FindItem)

A = #{1..20}
B = #{6..12}
C = A - B -->> #{1..5,13..20}
(@denist)
Joined: 11 months ago

Posts: 0

yes. that has to be slow. the algorithm shown by me is nothing close…

Ahh, never realised you could do that. Tried doing calculations on true/false in the past and just assumed that ruled out doing the same with bitarrays. Thanks heaps for the help both of you!

/edit; that really helps a lot, in other areas of my tool. I feel stupid now for not using bitarrays more frequently. I was almost always converting them…

And it seems like my use of many parts of max-script were lacking, eg with my function I posted above. I like the new one more;

fn GetUnSharedItems ArrayOne ArrayTwo = for SourceArray in ArrayOne where (finditem ArrayTwo SourceArray) == 0 collect SourceArray