Advertisement

Question on this maxscript

Started by July 09, 2014 10:23 PM
-1 comments, last by lucky6969b 10 years, 4 months ago

try(destroydialog orderPoints) catch()
rollout orderPoints "Order Points" width:200
(
	fn sortByPosComponent v1 v2 order:#(1,2,3) dir:1 = 
	(
		act = if v1.pos[order[1]] < v2.pos[order[1]] then -1 else if v1.pos[order[1]] > v2.pos[order[1]] then 1 else 
			if order[2] != undefined then sortByPosComponent v1 v2 order:(deleteitem order 1) else 0
		act*dir
	)
	label lb "Order:" align:#right offset:[-20,4] across:3
	dropdownlist order_dd items:#("xyz", "xzy", "yzx", "yxz", "zxy", "zyx") width:44 align:#left offset:[-16,0] tooltip:"Sorting Order"
	checkbox reverse_ch "Reverse" width:90 align:#left offset:[-14,3] tooltip:"Use Reverse Order"
	edittext base_ed text:"Pallete" width:194 align:#left offset:[-12,2] tooltip:"Point Base Name"
	
	button rename_bt "Rename Points" width:190 align:#left offset:[-8,2] tooltip:"Rename Selected Points\n + Control\t- All Points"
	
	fn makeOrder = for k=1 to 3 collect (bit.charasint order_dd.selected[k] - 119)

	on rename_bt pressed do undo "Rename Points" on 
	(
		nodes = if keyboard.controlpressed then selection else helpers
		pp = for p in nodes where iskindof p Point collect p
		if pp.count > 0 do
		(
			dir = if reverse_ch.state then -1 else 1
			qsort pp sortByPosComponent order:(makeOrder()) dir:dir
			id = 0
			d = orange/pp.count
			for p in pp do 
			(
				c = orange - id*d
				p.name = base_ed.text + (formattedprint (id += 1) format:"05d")
				p.wirecolor = c
			)
		)
		pp
	)
)
createdialog orderPoints

Pallet01 Pallet02 Pallet03 Pallet077...

The output is incorrect. There are 3 three objects in the first row that are named correctly.

The next several items are named incorrectly.

Any help?

Thanks Jack

This topic is closed to new replies.

Advertisement