Notifications
Clear all

[Closed] delete duplicted splines – need some help to finish it

Hi
this script is a piece of bigger script i’m working on… some other code line cause massive numbers of duplicated splines and i’m trying to fix it with these lines.

here is the thing , what it suppose to do is deleting all splines share same position exept one , what it do it delete all the splines , and 3 or 4 loops inside each other is too complicated for this !

script here




---- delete duplicated
		local	delete_shapes =#()
	
	
	for i in shapes where classof i == SplineShape do 
	(
CenterPivot i
	)
	
	arr = ( for i in shapes where classof i == SplineShape collect i )
	num = (for m = 1 to arr.count collect m)
	
	for i in arr do
		(
	for n = 1 to arr.count do (
	local to_del = ( for z in arr where (i.pos ) == (arr[n].pos) collect z )

			append  delete_shapes to_del

			--print to_del
		
		
		
	)
)
	--print delete_shapes
for i in delete_shapes do ( delete i )
	




any other idea to delete identical splines is welcomed too
thanx

2 Replies
 lo1

here you go…

fn deleteDuplicateSplines thresh:0.01 =
(
	local splines = for s in shapes where classof s == SplineShape collect s
	local toDelete = #()
	for s in splines where isValidNode s do
	(
		for x = splines.count to 1 by -1 do 
		(
			local spl = splines[x]
			if spl != s and distance s spl < thresh do
			(
				append toDelete spl
				deleteItem splines x
			)
		)
		
	)
	delete (makeUniqueArray toDelete)
)	

deleteDuplicateSplines()

thats much better than what i wrote
it works gr8

thanx