[Closed] A simple question
How to create a 10*10 spheres array via maxscript?
Just like this:
please help me to fill “X”, Thanks a lot!!
for i=1 to 100 do
(
a=sphere radius:1
a.pos=[X,X,0]
)
I think you are looking for something like this:
(
local arraySize = [10,10,1]
local sphereRad = 1
for x = 1 to arraySize.x do (
[indent]for y = 1 to arraySize.y do (
[indent]for z = 1 to arraySize.z do (
[indent]local a = sphere radius:sphereRad
a.pos = [sphereRad * x,sphereRad * y,sphereRad * z]
) -- end of z loop
[/indent]) -- end of y loop
[/indent]) -- end of x loop
[/indent]) -- end of script
Why do you need a loop from 1 to 100?
you can devide the i by 10 to get the x value and use ‘mod i 10’ for the y value or something like that.
Great,I also found it in the SDK example, I need to rewrite it to c# code.There is also a problem if those Bezier Shapes come from two different nodes,Do we need to transform their corresponding matrix?
It depends on what you want to get. But usually we expect the end result to look exactly the same as everything looked before attaching. So, yes, we have to transform the attached object in the space of the main node.
I rewrite them :
int boff = shape.SplineCount; for (int i = 0; i < attShape.SplineCount; ++i) { int index = shape.SplineCount; ISpline3D spline = shape.NewSpline(0, 1, 0); spline = attShape.GetSpline(i); for (int seg = 0; seg < spline.Segments / 3; ++seg) spline.SetMatID(seg, (ushort)(spline.GetMatID(seg) + mtlOffset)); shape.VertSel.Insert(shape.SplineCount - 1, spline.Verts); shape.SegSel.Insert(shape.SplineCount - 1, spline.Segments); shape.PolySel.Insert(shape.SplineCount - 1); shape.VertSel = attShape.VertSel; shape.SegSel = attShape.SegSel; shape.PolySel.Set(index, attShape.PolySel[i]); for (int j = 0; j < spline.KnotCount; ++j) spline.SetAux2(j, -1); } //copy over binds + offset for (uint i = 0; i < attShape.BindList.Length; i++) { attShape.BindList[i].PointSplineIndex += boff; attShape.BindList[i].SegSplineIndex += boff; shape.BindList.Append(attShape.BindList[i]); } for (uint i = 0; i < shape.BindList.Length; i++) { int index = 0; int spindex = shape.BindList[i].PointSplineIndex; if (shape.BindList[i].IsEnd) index = shape.GetSpline(spindex).KnotCount - 1; shape.BindList[i].BindPoint = shape.GetSpline(spindex).GetKnotPoint(index); shape.BindList[i].SegPoint = shape.GetSpline(spindex).GetKnotPoint(index); }
These are my test code:
//spls is List<IINOde> IObject sobj = spls[0].ObjectRef; ISplineShape spl = (ISplineShape)sobj; IBezierShape bzSpl = spl.Shape; for (int i = 1; i < spls.Count; i++) { ISplineShape nextspl = (ISplineShape)spls[i].ObjectRef; SRYDoAttach(bzSpl, nextspl.Shape,0); } bzSpl.UpdateSels(true); bzSpl.InvalidateGeomCache();
There is not any change for two splineshape s in my scene.Why?(using redraw views)