Move an object by using FFDbox

I need a script which allow to FFD modifier (by activate all control points) move an object vertically
Thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Haider of Sweden's picture

.

Way to go Miauu.
You're certainly a genius ;)

Kind regards
Haider
www.haider.se

miauu's picture

.

The code below will move all control points of the FFD modifier, applied on top of the stack of selected object along the world XYZ axis.

(
	function LocalFFDToWorld curObj topMod pos =
	(			
		objTM = curObj.objecttransform
		modTM = (getModContextTM curObj topMod) * topMod.lattice_transform.value
		modBBMin = getModContextBBoxMin curObj topMod
		modBBMax = getModContextBBoxMax curObj topMod
		size = modBBMax - modBBMin
		thePoint = ((modBBMin + pos * size) * (inverse modTM) * objTM)
	)
 
	function WorldPointToFFD curObj topMod pos = 
	(
		otm = curObj.objecttransform
		mtm = (getModContextTM curObj topMod)*topMod.lattice_transform.value
		bmin = getModContextBBoxMin curObj topMod
		bmax = getModContextBBoxMax curObj topMod
 
		v = (pos * (inverse otm) * mtm - bmin)/(bmax - bmin)
		for k = 1 to 3 where not (bit.isFinite v[k]) do v[k] = 0
		v
	)
 
	function ApplyNewFFDCPPositions offset: =
	(
		max modify mode
		local topMod = modpanel.getCurrentObject()
		if ( substring (topMod as string) 1 3 ) == "FFD" then
		(
			local curObj = selection[1]			
			--			
			theMaster = topMod[#master]
			theCount = theMaster.numsubs
			animateAll topMod
			--
			if classOf offset == point3 do
			(
				for cpIdx = 1 to theCount do
				(
					--	move the control points					
					local curPos = (theMaster[cpIdx].value)
					if curPos != undefined do
					(
						worldPos = LocalFFDToWorld curObj topMod theMaster[cpIdx].value
						worldPos.x += offset.x
						worldPos.y += offset.y
						worldPos.z += offset.z
						localPosShifted = WorldPointToFFD curObj topMod worldPos
						(theMaster[cpIdx].value) = localPosShifted
					)
				)
			)
		)
		else
			messagebox "Invalid selection" title:"Invalid Selection"
	)
	--
	ApplyNewFFDCPPositions offset:[0,0,50]
)
usaqmuri's picture

..

---

zb

usaqmuri's picture

Excellent

THANK YOU :)
you're a scripting genius

zb

miauu's picture

.

Thanks.. but I still consider myself as a maxscript novice. :)

usaqmuri's picture

.

Hi Kostadin
I know about the pivots but it's does not matter for me

I give the advantage to FDD modifier because i have a lot of scenes, all those scenes a little bit similar to each other. also they all have a different number of objects and vertices and are attached to each other. Every scene contain a few vertices which i should to move

So every time when i will be opening  these scenes in each of them i will have already selected vertices with FDD modifier. Thus it will be easier to determine the vertices, which i need to move
Hope that i could explain my task

THANKS

zb

miauu's picture

.

You want to move all control points of the FFD mod at once with given value?
For example

move allCP [0,0,100] -- will move all control points 100 units on Z axis

The movement must be in world Z axis, or in modifiers local Z axis?

miauu's picture

.

Why you need that?
What is the difference between using the FFD modifier control points and moving the object by just select and move it?

Moving the object, using the FFD modifier moves the geometry, but the pivot will not be moved. You can acheive the same result by selecting all vertices of hte object and moving them. The geometry will be moved, but the pivot will not be moved.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.