Notifications
Clear all

[Closed] Loop through elements?

Hi. How would I loop through each element in my model and give each element a different smoothing group?

2 Replies

You can adapt for example this collectElements function to set the smoothing groups on each element instead of collecting them. Or just collect them first and loop through and set the smoothing groups later on.

recursion and a function argument is an elegant solution…

for an editable poly something like…


  (
  	smg = 1
  	fn setElementSmoothGroup pobj faces =
  	(
  		polyop.setFaceSmoothGroup pobj faces smg;
  		smg *= 2;
  	)	
  
  	fn enumElements pobj faces func =
  	(
  		if not faces.isempty then
  		(	
  			efaces = polyop.getElementsUsingFace pobj ((faces as array)[1]);
  			func pobj efaces;
  			enumElements pobj (faces - efaces) func;
  		)
  	)	
  	enumElements $ ($.faces as bitarray) setElementSmoothGroup;
  ) 

someone will come along with a faster solution before long