Nukie
13-07-2007, 03:14 PM
Hi,
I have started learning MAXScript, and for that I'm following the tutorials that come with max. At this point I'm following the "How To" tutorials, and so far i'm at tutorial 5 "Selecting Non-Quad Polygons".
The tutorial itself is clear and it also works, but I thought "Lets try some things for myself" so instead of making a MacroScript I'm trying to create a rollout with 2 buttons: One for selecting the Non-Quads and one for deselecting them. Now this isnt so much of a problem and the rollout works, but the button (so far I'm still trying to get the "Select All" button to work) doesnt.
When I select my model (for testing I'm using a simple GeoSphere converted to Edit Poly) the script gives me the following error:
-- Unable to convert: true to type: Integer
The error highlights this line from the code:
polyop.setfaceselection base_obj face_selection
And here is the complete code:
rollout SelectNonQuads "Select all Non-Quad Polygons"
(
label lab "Select all Non-Quad Polygons"
button select "Select All" pos:[10,30]
button deselect "Deselect All" pos:[80,30]
on select pressed do
(
local face_selection = #()
local base_obj = $.baseobject
local num_faces = polyop.getnumfaces base_obj
for f = 1 to num_faces do
(
local num_face_verts = polyop.getfacedeg base_obj f
if num_face_verts != 4 do face_selection[f] = true
)
polyop.setfaceselection base_obj face_selection
max modify mode
modpanel.setcurrentobject base_obj
subobjectlevel = 4
)
)
createdialog SelectNonQuads width:160 height:60
Maybe worth to mention I'm not a die-hard programmer :p
I have started learning MAXScript, and for that I'm following the tutorials that come with max. At this point I'm following the "How To" tutorials, and so far i'm at tutorial 5 "Selecting Non-Quad Polygons".
The tutorial itself is clear and it also works, but I thought "Lets try some things for myself" so instead of making a MacroScript I'm trying to create a rollout with 2 buttons: One for selecting the Non-Quads and one for deselecting them. Now this isnt so much of a problem and the rollout works, but the button (so far I'm still trying to get the "Select All" button to work) doesnt.
When I select my model (for testing I'm using a simple GeoSphere converted to Edit Poly) the script gives me the following error:
-- Unable to convert: true to type: Integer
The error highlights this line from the code:
polyop.setfaceselection base_obj face_selection
And here is the complete code:
rollout SelectNonQuads "Select all Non-Quad Polygons"
(
label lab "Select all Non-Quad Polygons"
button select "Select All" pos:[10,30]
button deselect "Deselect All" pos:[80,30]
on select pressed do
(
local face_selection = #()
local base_obj = $.baseobject
local num_faces = polyop.getnumfaces base_obj
for f = 1 to num_faces do
(
local num_face_verts = polyop.getfacedeg base_obj f
if num_face_verts != 4 do face_selection[f] = true
)
polyop.setfaceselection base_obj face_selection
max modify mode
modpanel.setcurrentobject base_obj
subobjectlevel = 4
)
)
createdialog SelectNonQuads width:160 height:60
Maybe worth to mention I'm not a die-hard programmer :p