Notifications
Clear all

[Closed] points at object selection pivots

Hi, I am trying to write a simple script that will allow me to create a point helper(s) at the pivot(s) of a selected object/objects. I have looked on scriptspot but the available script is no longer available. I use MEL mostly and understand the basic requirement for doing this requirement in MAYA, but am having problems getting the for loop right. I have made a start which makes a point helper at the origin for each of the selected objects which are in an array, but I am just having a bit of a stumble at the syntax for writing the rest. Not sure if I need a counter for loop such as:

for (i = 0; i == names_array.count; i++)

but am not sure if the syntax is correct.

Any pointers would be greatly appreciated. I have some Maxscript resources to go through, but am pressed at the moment to be able to divert any time to absorb it and am hoping to get a quicker response that I can implement asap. The code below is probably in need of tidying up, but seems to be a decent start.

Many thanks in advance.

names_array = for i in $* collect i.name
sort names_array

[b]for i in 1 to names_array.count do
(

    Point pos: [0,0,0]

)[/b]

3 Replies

i’d do something like:

selectionArray = selection as array

for i = 1 to selectionArray.count do
(
myPoint = Point pos: selectionArray[i].pivot
myPoint.name = (“Point_”+selectionArray[i].name)
)

hey Malcolm,

I wanted to same thing a while back, so wrote a quick script as part of my rigging toolbox. Hopefully it will be useful to pick apart and see what is going on – it’s essentially matt’s code with a UI!

rollout PointParentRo "Point Daddy" width:165 height:155
(		
	fn SetHelperDisplayFlags size cross centermarker box axistripod =
	(
		for i in selection where classof i == point do 
		(
		i.size = size 
		i.cross = cross
		i.centermarker = centermarker
		i.box=box
		i.axistripod=axistripod		
		)
	)	
	
	colorPicker cpPt "" pos:[5,4] width:20 height:14 				
	button btnCreatePoint "Create" pos:[84,108] width:77 height:42 autoDisplay:true  	  	 		
	edittext edtPrefix "" pos:[21,85] width:136 height:14 enabled:false multiline:false
	checkbox chkAddPrefix "" pos:[7,85] width:14 height:16 checked:false
	checkbox chkCM "Center" pos:[31,33] width:53 height:16
	spinner spnsize "Size" pos:[22,109] width:54 height:16 enabled:true range:[0,100,2]
	GroupBox grpd "Display:" pos:[3,19] width:158 height:48
	checkbox chkX "Cross" pos:[92,48] width:46 height:16 checked:true
	checkbox chkBox "Box" pos:[31,48] width:45 height:16 checked:true
	checkbox chkAx "Axis" pos:[92,33] width:43 height:16
	checkbox chkObjwc "Use Object Wirecolor" pos:[32,3] width:120 height:18
	checkbutton ckbLink "Make Parent" pos:[4,130] width:78 height:19 highlightColor:(color 8 61 138) checked:true
	GroupBox grpn "Add Name Prefix" pos:[3,68] width:158 height:35
	
	on btnCreatePoint pressed do
	(
	local _pts = #()
	   for i in selection do
	   (
		mpt = point transform:i.transform wirecolor:(if chkObjwc.checked then i.wirecolor else CpPt.color) name:(uniquename (edtprefix.text + "PointControl_"))  size:spnSize.value cross:chkX.state center:chkCM.state box:chkBox.state axistripod:chkAx.state
		append _pts mpt		
		if ckblink.checked then i.parent = mpt		   
	   )
	select _pts
	)
	on chkAddPrefix changed state do edtPrefix.enabled= state
	on chkCM changed state do
		SetHelperDisplayFlags spnSize.value chkX.state chkCM.state chkBox.state chkAx.state
	on spnsize changed val do
		SetHelperDisplayFlags val chkX.state chkCM.state chkBox.state chkAx.state
	on spnsize buttondown do flagForeground selection true
	on spnsize buttonup do flagForeground selection false
	on chkX changed state do
		SetHelperDisplayFlags spnSize.value chkX.state chkCM.state chkBox.state chkAx.state
	on chkBox changed state do
		SetHelperDisplayFlags spnSize.value chkX.state chkCM.state chkBox.state chkAx.state
	on chkAx changed state do
		SetHelperDisplayFlags spnSize.value chkX.state chkCM.state chkBox.state chkAx.state
)
createdialog PointParentRo style:#(#style_toolwindow, #style_sysmenu)

thanks very much guys, this is a massive help. am having lots of fun getting used to Maxscript again, so this is truly appreciated. :applause:

Hope I can return the favour one day.