Hi everyone, I’ve started working with max again lately. And wanted to use a collection of my old scripts again. But a particular script isn’t working with the newer version of max. I can’t figure out whats wrong with it. Here is the code with the faulty bit commented out:
global myGrid = undefined
fn _alignViewToFace obj orthoView:True =
(
if obj != undefined and classOf obj == Editable_Poly then
(
selectedFaces = (getfaceselection obj) as array
if selectedFaces.count == 1 then
(
local myCam = ::createCamera()
print obj
myCam.dir = (polyOp.getFaceNormal obj selectedFaces[1])
viewport.setCamera myCam
completeRedraw()
delete myCam
max zoomext sel
if orthoView == True then
(
viewport.setType #view_iso_user
)
)
else
(
messageBox "Needs 1 Face"
)
)
else
(
messageBox "Need Editable Poly"
)
)
fn _deleteGridIfItExists =
(
if myGrid != undefined then
(
if isDeleted myGrid == False then
(
delete myGrid
)
)
)
/* BELOW DOES NOT WORK */
/*
fn _getRotationArray axis =
(
local rotArray = #(0, 0, 0)
case axis of
(
"x":
(
* * * *rotArray[1] = 0
* * * *rotArray[2] = 90
* * * *rotArray[3] = 0
* *)
* *"-x": *
(
* * * *rotArray[1] = 0
* * * *rotArray[2] = -90
* * * *rotArray[3] = 0
* *)
* *"y": *
(
* * * *rotArray[1] = -90
* * * *rotArray[2] = 0
* * * *rotArray[3] = 180
* *)
* *"-y": *
(
* * * *rotArray[1] = 90
* * * *rotArray[2] = 0
* * * *rotArray[3] = 0
* *)
* *"z": *
(
* * * *rotArray[1] = 0
* * * *rotArray[2] = 0
* * * *rotArray[3] = 0
* *)
* *"-z": *
(
* * * *rotArray[1] = 0
* * * *rotArray[2] = 180
* * * *rotArray[3] = 0
)
default:
(
messageBox "getRotationArray = Default!"
)
)
rotArray
)
*/
fn _alignViewportToGeometry obj alignTo:"z" gridOn:True gridSize:1000 gridSquare:50 orthoView:True =
(
local myCam = ::createCamera()
local rotArray = _getRotationArray alignTo
::align myCam obj rotX:rotArray[1] rotY:rotArray[2] rotZ:rotArray[3]
viewport.setCamera myCam
completeRedraw()
delete myCam
max zoomExt sel
if orthoView == True then
(
viewport.setType #view_iso_user
)
if gridOn == True then
(
::myGrid = ::createGrid lengthValue:gridSize widthValue:gridSize gridValue:gridSquare
::align myGrid obj rotX:rotArray[1] rotY:rotArray[2] rotZ:rotArray[3] offsetZ:-1000
select myGrid
max activate grid object
select obj
)
)
The error message:
– Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2014\scripts echniArt echniArt-alignViewToMesh.ms; position: 980; line: 58
– Syntax error: at string, expected :
– In line: * *"-x":
Thank you for your time and help.