Notifications
Clear all

[Closed] Group Pivot Point ?

Hello,

  I’m trying to make a script that imports 3ds files moves the pivot point to the center bottom, moves the object to 0,0,0 and saves the file

But for some reason that I don’t know the pivot doesn’t set correctly when I run the script, it works if I run just that line
Global Root
  Global filelist
  GLobal OpenSave
  
  fn GetPath =
  (
  	Root = getSavePath caption:"Select the Mesh Folder:" -- puts the path in a variable
  	OpenSave.btn_getPath.text = Root as string -- displays the path on the rollout
  	
  	filelist = getFiles (Root + "\\*.3ds") -- gets the list of files
  	OpenSave.lbl_Info_NumFiles2.text = filelist.count as string -- updates the counter display
  )
  	
  rollout OpenSave "--G-Tools--	 Open.Center.Save	v1.00" width:268 height:85
  (
  	button btn_getPath "Folder" pos:[3,5] width:261 height:18 toolTip:"Select the Max File's Folder"
  	progressBar pb1 "ProgressBar" pos:[7,74] width:255 height:8
  	button btn_Go "Go" pos:[6,30] width:63 height:39
  	groupBox grp_info "Information" pos:[73,25] width:188 height:43
  	label lbl_Info_NumFiles "Number of files:" pos:[80,39] width:77 height:14
  	label lbl_Info_NumFiles2 "0" pos:[158,40] width:35 height:14
  	
  	on btn_getPath pressed  do
  	(
  	 GetPath ()
  	)
  	
  	on btn_Go pressed do
  	(
  		 for i in 1 to filelist.count do
  		 (
  		pb1.value = 100.*i /filelist.count
  		importFile filelist[i] #NoPrompt
  		delete cameras
  		delete lights
  		delete helpers
  		-- makes a group out of the objects
  		group objects name:"TempGroup"
  		-- moves the pivot to the bottom center		
  		for obj in $TempGroup do obj.pivot = 
  				(					
  				[(obj.max.x+obj.min.x)/2, (obj.max.y+obj.min.y)/2, obj.min.z]											
  				)
  			
  		$TempGroup.pos = [0,0,0]		
  		
  		ungroup $TempGroup 	
  		max tool zoomextents
  		viewport.SetRenderLevel #smoothhighlights
  		--savemaxfile (filelist[i] + ".Max")
  		
  		--resetMaxFile #noPrompt
  		)
  	)
  )
  
  Createdialog OpenSave
Cloud some one help me out.?

Thanks,

Guillermo Leal

3 Replies

Hi,

I think you need to use
for obj in $TempGroup.children do obj.pivot = …

Also, objects have a .center property so you can use [obj.center.x, obj.center.y, obj.min.z] to get the objects center bottom.

Thanks for yours suggestions.

Its now working correctly, it turns out I was moving the pivot when trying to move the object. Now I setup the pivot of the group and then move the object.

Thanks again.
Guillermo Leal