Notifications
Clear all

[Closed] SimpleObject problem

Hello,
I am trying to script a SimpleObject via MaxScript. Its a Box with hollow and
height-subdivision(detail) spinners. It works fine till the moment I spinn the
detail-spinner up and down. I get a error-message saying something
like(I work with a german 3dsmax):
“unknown system-exeption”!?

Here is the code:

 
 
plugin simpleObject Hollow_Box
 
name:"Finns Box"
 
classID:#(0x2fa36406, 0x27749fb7)
 
category:"Finns Primitives"
 
(
 
parameters main rollout:params
 
(
 
height type:#worldUnits ui:height default:10
 
width type:#worldUnits ui:width default:10
 
depth type:#worldUnits ui:depth default:10
 
hollow type:#float ui:hollow default:0
 
detail type:#float ui:detail default:2
 
)
 
rollout params "SL Box Parameters"
 
(
 
spinner height "Height Z" type:#worldunits range:[0.1,100,100]
 
spinner width "Width X" type:#worldunits range:[0.1,100,100]
 
spinner depth "Depth Y" type:#worldunits range:[0.1,100,100]
 
spinner hollow "Hollow" type:#float range:[0,0.95,0.5] scale:0.01
 
spinner detail "Detail" type:#integer range:[1,10,2] scale:1
 
)
 
on buildMesh do
 
(
 
vert_array=#()
 
face_array=#()
 
 
 
--ground vertices
 
base_v=#([0,0,0],[width,0,0],[width,depth,0],[0,depth,0],[width/2-(width/2)*hollow,depth/2-(depth/2)*hollow,0],[width/2+(width/2)*hollow,depth/2-(depth/2)*hollow,0],[width/2+(width/2)*hollow,depth/2+(depth/2)*hollow,0],[width/2-(width/2)*hollow,depth/2+(depth/2)*hollow,0])
 
--ground faces
 
base_f=#([1,4,5],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,8],[3,8,4],[8,5,4])
 
unten_verts=base_v
 
unten_faces=base_f
 
for f=1 to base_v.count do( --center verts to mouseclick
 
base_v[f].x-=width/2
 
base_v[f].y-=depth/2
 
base_v[f].z-=height/2
 
)
 
join vert_array unten_verts
 
join face_array unten_faces
 
--top vertices
 
add=8*detail --height subdevisions
 
oben_f=#([9+add,13+add,12+add],[9+add,14+add,13+add],[9+add,10+add,14+add],[10+add,15+add,14+add],[10+add,11+add,15+add],[11+add,16+add,15+add],[11+add,12+add,16+add],[16+add,12+add,13+add])
 
join face_array oben_f
 
--other verts
 
heightdevided=(height/detail)
 
heigth_v=#()
 
height_v=copy base_v #noMap
 
for i=1 to detail*8 do(
 
 
 
v1=height_v[i].x
 
v1+=0
 
v2=height_v[i].y
 
v2+=0
 
v3=height_v[i].z
 
v3+=heightdevided
 
append height_v [v1,v2,v3]
 
 
 
)
 
 
 
--outside faces
 
height_f=#()
 
for a=1 to height_v.count by 8 do (
 
for x=0 to 2 do (
 
 
 
 
 
face1=[a+x,a+x+9,a+x+8]
 
face2=[a+x,a+1+x,a+x+9]
 
append height_f face1
 
append height_f face2
 
)
 
 
 
face3=[a+3,a+8,a+11]
 
face4=[a+3,a,a+8]
 
append height_f face3
 
append height_f face4
 
 
 
)
 
join vert_array height_v
 
join face_array height_f
 
--inside hollow faces
 
height_f=#()
 
for a=5 to height_v.count by 8 do (
 
for x=0 to 2 do (
 
 
 
 
 
face1=[a+x,a+x+8,a+x+9]
 
face2=[a+x,a+9+x,a+x+1]
 
append height_f face1
 
append height_f face2
 
)
 
 
 
face3=[a+3,a+11,a+8]
 
face4=[a+3,a+8,a]
 
append height_f face3
 
append height_f face4
 
 
 
)
 
 
 
join vert_array height_v
 
join face_array height_f
 
--------------------------------------
 
setMesh mesh vertices:vert_array faces:face_array
 
for i=0 to mesh.numFaces do (
 
setFaceSmoothGroup mesh i 0
 
)
 
)
 
tool create
 
(
 
on mousePoint click do
 
case click of
 
(
 
1: nodeTM.translation = (gridPoint+[0,0,height/2])
 
2: #stop
 
)
 
)
 
)
 


Can anyone figure out why the script tends to crash?

Thanks, Finn

5 Replies

Can you upload the script as an attachment? That would make it easier to inspect.

  • Michele

Sorry, but in my posting rules I am not allowed to do attachments
(“You may not post attachments”). Maybe thats because this is my first
thread! Cant you copy-paste the code into a new maxscript window?

I found out that its this part of code, which makes trouble:

for i=0 to mesh.numFaces do (
 setFaceSmoothGroup mesh i 0
 )

But why is that doing problems? Cant I smooth faces in a SimpleObject-plugin??

Thanks, Finn

works for me:

for each in mesh.faces do 
(
		   setFaceSmoothGroup mesh each.index 1
)

That works for me, too!!

Thank you very much!

Finn