# Import rectangular/square shapes and preserve rotation in 3dsmax

Hello there. Does anybody know any way of importing (lets say 100,000 so that no one tells me to do this manually) rectangles from any kind of vector drawing program and preserve their (x,y) rotation when imported into 3dsmax? Whenever I import shapes from ai,dxf etc, whatever their origin or method of creation, their x,y rotation is always zero. And that's when they are a true rectangle with perfect 90 degree angles.

Now, what I REALLY want is something that basically "guesses" their rotation values from imported splines that are "approximately" rectangles. Maybe guess the rotation from one of the sides of the (huge number of) shapes, perhaps.

I suppose this is quite ludicrous, but if anyone can help me with the first problem I'd be pretty happy.

Any ideas? Anyone?

## Comment viewing options

### Even simpler :)

Remove normalize from row1 and row2 and add it to row 3 (or you get an arbitrary scaling in Z).

```(
for obj in objects where superClassOf obj == shape do (
if classOf obj != splineShape do convertToSplineShape \$
local k1 = getKnotPoint obj 1 1
local k2 = getKnotPoint obj 1 2
local k3 = getKnotPoint obj 1 3
local row1 = k2 - k1
local row2 = k3 - k2
local row3 = normalize (cross row1 row2)
local row4 = obj.pos
local tm = matrix3 row1 row2 row3 row4
obj.transform *= inverse tm
resetXForm obj
collapseStack obj
obj.transform *= tm
)
)```

### That's great! I'm sure it'll

That's great! I'm sure it'll work - I just realised, quite a lot of my favourite maxscripts are written by you!

Right, no more questions, I'm off to learn maxscript!

Thankyou!

### Since I got such a great

Since I got such a great reply the first time, I thought I might push my luck with one last question. So the pivot thing works great, but it would be nice if max somehow "believed" that the lengths of the sides of those rectangles were a scale value of some arbitrary square. So lets say this imaginary square has sides length 1x1. And one of the rectangles has sides length 1.6 x 2.3. How do I get max to think the rectangle has been scaled 160% on the x axis and 230% on the y axis? And do this for all the rectangles at once?

### you could always apply a

you could always apply a xform modifier and scale the modifier gizmo. From there you could collapse the stack or leave the xform to mess with it by hand if need be. This will give you the ability to scale the object with out messing with the actual transform of the object. I believe there is a way to actually mess with the objects scale on a non transform base.

```xMod = xForm()
xMod.gizmo.scale = [1 , 1.5 , 2] --be what ever scale you want.  Remember this is in parent space
addModifier Obj xMod --obj is object which you want the xform applied to```

### Wowza! Thanks a lot man, I'm

Wowza! Thanks a lot man, I'm off to try that out right now....

Yeeeeesss!!! It works! You were just missing a final bracket in the script, but it works!

Thanks again!

### This should work:

```(
for obj in objects where superClassOf obj == shape do (
if classOf obj != splineShape do convertToSplineShape \$
local k1 = getKnotPoint obj 1 1
local k2 = getKnotPoint obj 1 2
local k3 = getKnotPoint obj 1 3
local row1 = normalize (k2 - k1)
local row2 = normalize (k3 - k2)
local row3 = cross row1 row2
local row4 = obj.pos
local tm = matrix3 row1 row2 row3 row4
obj.transform *= inverse tm
resetXForm obj
collapseStack obj
obj.transform *= tm
)```