Started with maxscript : Polygon coordinate
Hi guys,
i try to learn maxscript and i'm actually freeze in my code since a fex days..
I would like to move an object (let say a Teapot) on a polygon from an other object.
So here, i start the script by selected some polygon and set the selection on an array.
Next i select one polygon from this array and .....
how can i get the coordinate of this poligon ?
so i'll be able to move the teapot like:
x=(coordsys world ???.pos.x)
y=(coordsys world ???.pos.y)
z= (coordsys world ???.pos.z)
move Teapot001 [x,y,z]
Here is my code:
rollout myscript "test width:280 height:141
(
GroupBox 'grp1' "Object on Element" pos:[10,10] width:255 height:112 align:#left
pickbutton 'itemdest' "-- none --" pos:[140,30] width:120 height:20 align:#left
label 'lbl1' "Main Object" pos:[20,30] width:100 height:15 align:#left
button 'btn1' "Move" pos:[140,95] width:120 height:20 align:#left
on itemdest picked obj do
(
itemdest.text = obj.name
dest = obj
)
on btn1 pressed do
(
select dest
max modify mode
subobjectlevel = 4
numFaces = polyOp.GetNumFaces dest
angleSelection = #{}
prov1 = #()
for f=1 to (numFaces) do
(
faceNorm = polyOp.getFaceNormal dest f
angle = acos faceNorm.z
if ((angle >= 0) and (angle <= 10)) then angleSelection[f] = true
)
polyOp.setFaceSelection dest angleSelection
SelectedFaces = getFaceSelection dest
if SelectedFaces.numberset != 0 do prov1 += SelectedFaces
temp=polyop.setfaceselection dest prov1[random 1 prov1.count]
)
)
Thx for helping !
Comments
.
1) select your dest object(which you will pick with the [-- none --] button), go to Polygon subobject level and select one polygon.
2) select the object you want to move
3) press the [ Move ] button
Tools and Scripts for Autodesk 3dsMax
thx for helping !
thx for helping !