Notifications
Clear all

[Closed] Slice Modifier Position not Working?

Hi guys,

It’s been a long time. Any of you guys know why the position of a slice modifier is not working through script? I have been trying to write a script that breaks a mesh in X number of slices using a couple of slice modifiers to do so but the position of it seems to be only coming at the pivot point of my meshes. I am using Max Design 2014. Below you can find my code:


horizontalDivisions = 3
verticalDivisions = 3

refPoint = point()
refPoint.pos = [0,0,0]

boundingBox = nodeGetBoundingBox $ refPoint.transform

boundingBoxLimitA = boundingBox[1]
boundingBoxLimitB = boundingBox[2]

horizontalDistance = (boundingBoxLimitB.x - boundingBoxLimitA.x)/horizontalDivisions
verticalDistance = (boundingBoxLimitB.y - boundingBoxLimitA.y)/verticalDivisions

--posX = boundingBoxLimitA.x + horizontalDistance
posX = (-(horizontalDivisions)/2) * horizontalDistance
posY = (-(verticalDistance)/2) * verticalDistance


for i = 1 to (horizontalDivisions - 1) do
(	
	posX = posX + horizontalDistance
	for j = 1 to (verticalDivisions - 1) do
	(	
		posY = posY + verticalDistance		
		newObj = copy $
		
		--Horizontal Split
		horizontalSlice = sliceModifier()
		horizontalSlice.Slice_Type = 2		
		horizontalSlice.Slice_Plane.pos = [posX, 0, 0]
		horizontalAngle = (eulerAngles 90 0 0) as quat
		horizontalSlice.Slice_Plane.rotation = horizontalAngle
		addmodifier newObj horizontalSlice
		--Vertical Split
		verticalSlice = sliceModifier()
		verticalSlice.Slice_Type = 2		
		verticalSlice.Slice_Plane.pos = [0, posY, 0]
		verticalAngle = (eulerAngles 0 90 0) as quat
		verticalSlice.Slice_Plane.rotation = verticalAngle
		addmodifier newObj verticalSlice
		
		convertToMesh newObj	
			
		
	)
	print ("Pos X")
	print posX
	
)

Any ideas or help would be immensely appreciated.

Best,

G.

1 Reply

you can see that everything works as expected:

delete objects
b = box width:10 length:10 height:40
xnum = 2
for k=1 to xnum do
(
	s = sliceModifier name:("SliceX " + k as string)
	s.slice_plane.rotation = prerotateY (matrix3 1) 90
	s.slice_plane.pos.x = b.min.x + (b.max.x - b.min.x)*k/(xnum+1)
	addmodifier b s
)	
ynum = 3
for k=1 to ynum do
(
	s = sliceModifier name:("SliceY " + k as string)
	s.slice_plane.rotation = prerotateX (matrix3 1) 90
	s.slice_plane.pos.y = b.min.y + (b.max.y - b.min.y)*k/(ynum+1)
	addmodifier b s
)	
znum = 5
for k=1 to znum do
(
	s = sliceModifier name:("SliceZ " + k as string) 
	s.slice_plane.pos.z = (b.max.z - b.min.z)*k/(znum+1)
	addmodifier b s
)