Notifications
Clear all

[Closed] Anyone knows if such maxscript exists?

What I want to do is

  1. Collect all point helpers (or pick them)
  2. Sort them in ascending coordinates. (Better off if I can choose which axis is the first priority)
  3. Give them a name
    so it’s like this

Pallet001	Pallet004	Pallet007
Pallet002	Pallet005	Pallet008
Pallet003	Pallet006	Pallet009

Of course, it runs down to all axis.
Thanks
Jack

8 Replies
1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

the tool you are asking is very specific. but it’s easy to make anything more generally used.
something like this:

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
 + Control	- 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

/*
delete objects
count = 100
seed = 0
for k=1 to count do point pos:(random -[100,100,100] [100,100,100]) 
*/

the key thing there is the sorting method i use. check if you are interested

I like this “orange” method.

Thanks Denis,
I’ll try that tonight.
Jack

Hello there,
Thanks for the script, it works on the first trial. But it has errors when I run on the second scene. Any ideas why?

2 Replies
(@denist)
Joined: 10 months ago

Posts: 0

sortByComponent has to be replaced with sortByPosComponent
(i’ve fixed it in the code posted above)

(@lucky6969c)
Joined: 10 months ago

Posts: 0

Let me try that!
Really Thanks

Update:
Thanks, it works.
Have fun

Jack

[del]…

Sorry for resurrecting this thread.

I lately reopen the script to test some new projects.
and find something funny. While there are other helpers (points)
in the scene, I pressed control when I clicked on the left mouse button,
The whole lot of helpers changed names, but not quite in the right order.
I found that some helpers were not orange, but in a gradient between black
and orange. Any ideas why?
Thanks
Jack