View Full Version : MAXScript Listener, function for undefined!
SevenDeserts 04-04-2005, 05:48 AM hi
I used MAXScript Listener to Record my work in MAX, and I get this script, so I saved it then when I came to run it I got the error below.
actionMan.executeAction 0 "40010" -- MAX Script: MAXScript Listener
$.name = "Shape1"
$.name = "Shape2"
$.name = "Shape3"
$.name = "Shape4"
$.name = "Shape5"
$.name = "Shape6"
$.name = "Shape7"
$.name = "Shape8"
$.name = "Shape9"
$.name = "Shape10"
$.name = "Shape11"
$.name = "Shape12"
clearSelection()
select $Shape11
select $Shape12
actionMan.executeAction 0 "40140"
$.name = "Group01"
clearSelection()
select $Shape1
select $Shape2
actionMan.executeAction 0 "40140"
$.name = "Group02"
clearSelection()
select $Shape9
select $Shape10
actionMan.executeAction 0 "40140"
$.name = "Group03"
clearSelection()
select $Shape5
select $Shape6
actionMan.executeAction 0 "40140"
$.name = "Group04"
clearSelection()
select $Shape7
select $Shape8
actionMan.executeAction 0 "40140"
$.name = "Group05"
clearSelection()
select $Shape3
select $Shape4
actionMan.executeAction 0 "40140"
$.name = "Group06"
-- Error occurred during fileIn in <File:C:\Documents and Settings\yty\Desktop\koko.mcr>
>> MAXScript FileIn Exception: -- No ""select"" function for undefined <<
I got this message:
Windows Message is : _ _ NO ""select"" function for undefined
and in script window it marked select $Shape12 with black line!
Where is the problem here? can you help here, please!
regards
|
|
galagast
04-04-2005, 07:54 AM
whenever you write "$" in the listener(or any maxscript eindow), it would expect you to have an object selected...
so if you try tryping it and pressing enter without any object selected, then you'd get "undefined"...
now if you try to type it again, but hav an object selected, you'd get a few properties of the object selected. (Class:Name @ [position])
lastly if you create, say a box, named Box01, deselect everything and type in Select $Box01, the script would select the box for you.
in your first few lines, evaluating $.name = "Shape1" might cause an error if you have no object selected.
try selecting any object and type in $.name... you'd get the object's name in the listener...
so if you type in $.name = "SevenDeserts" , this means that you're renaming your object to "SevenDeserts".
But this doesnt mean that selecting an object and running the script will guarantee it to work...
if you look at those lines with $.name with them, and have an object seleted, running those lines will only overwrite the objects' name, returning only the value of last line of code with $.name = on.
so say we select an object & run the script, max will first rename your object using the line $.name = "Shape1"
... it will repeat the process until it reaches the line $.name = "Shape12"
... so now your object will have a name "Sphape12"
the next line now states a function "Clearselection()" and it does what it says..
...now to the next line, (this is where the error really occured)
select $Shape11
... first thing, usually when max highlights a line of code, it means that the error is the line or lines of code before the highlighted line. :D
so you say that select $Shape12 was marked or was highlighted, the error would most probably be the line above it. which is select $Shape11
The error, probably... is only bacause, $Shape11 doesnt exist. so selecting it is not possible, which is why the listener returns an error No ""select"" function for undefined
which basically means max cant perform a "Select" operation for $Shape11 because it just cant find the object.
I hope this helps... and maybe you could also explain what you wanted to do so that I or any other reader may have a clear idea as to how to help you. :thumbsup:
SevenDeserts
04-05-2005, 12:20 AM
hi,
thank you galagast for this nice reply, I still face some problems so I decided to show you what I want to do in a picture its here.
Please help me to give these objects names then group them, I want to do all of this by a script!
regards.
http://www.ta7di.com/max/3dsmax.jpg
galagast
04-05-2005, 07:32 AM
thats a very informative illustration :)
rollout sevendeserts_auto_group "SevenDeserts Auto-Group" width:240 height:260
(
local updatemylist, rengroup --varibles used for functions
local my_objs = #() --collection of objects selected
local newname_arr = #() --collection of new object names
local item_count
local auto_group = true
checkbutton grp_chk "ENABLE" pos:[5,5] width:230 height:25 tooltip:"Enable Selection->List Update"
edittext prefix_edt "Object:" pos:[10,50] width:220 height:17 text:"Shape"
edittext grp_edt "Group:" pos:[10,70] width:220 height:17 text:"Group"
listbox obj_lst "" pos:[5,100] width:112 height:7 across:2
listbox newobj_lst "" pos:[120,100] width:115 height:7
spinner obj_spn "Limit:" pos:[18,205] width:65 height:16 range:[2,100,2] type:#integer
button grp_bot "Group" pos:[120,200] width:115 height:25 tooltip:"Groups the objects on the list"
checkbox auto_chk "" pos:[93,205] height:15 checked:true
GroupBox set_grp "Prefix:" pos:[5,35] width:230 height:60
GroupBox info_grp "" pos:[5,225] width:230 height:30
label info_lbl "" pos:[10,235] width:220 height:15
fn updatemylist =
(
sel = selection as array --collect the selection
if sel.count != 0 then --if the selection is not empty...
(
-- check if the selection is inside a group
-- if its inside a group, do not add it to the list
if try((not (isgrouphead sel[1].parent)))catch(true) do
(
my_objs = sel
item_count = sel.count
name_sel = for i in sel collect i.name --collect all the names
the_prefix = sevendeserts_auto_group.prefix_edt.text
-- next line of code will create a dummy mesh, which will have
-- a uniquename based on the given prefix.
-- The purpose of this is to have a preview of the uniquename.
-- It is deleted afterwards.
if item_count != 0 do
(
dummy_arr = #()
for i in 1 to item_count do
(
print sel[i].name
pre_mesh = mesh name:(uniquename the_prefix)
hide pre_mesh
append newname_arr pre_mesh.name
append dummy_arr pre_mesh
)
delete dummy_arr
)
-- fill in the items for our listboxes
sevendeserts_auto_group.newobj_lst.items = newname_Arr
sevendeserts_auto_group.obj_lst.items = name_Sel
-- if the limit is reached, then do the grouping
obj_limit = sevendeserts_auto_group.obj_spn.value
if item_count == obj_limit and auto_group do rengroup()
)
)
else
(--if there is no selection, empty the arrays
obj_lst.items = newobj_lst.items = #()
)
)
fn rengroup =
(
if my_objs != undefined do
(
for i in 1 to item_count do
(-- rename the objects accordingly
my_objs[i].name = newname_arr[i]
)
-- group the objects
the_grp = group my_objs name:(uniquename (grp_edt.text)) select:false
-- create an info text
the_info = ("Created: " + the_grp.name + " with " + item_count as string + " items.")
info_lbl.caption = the_info
clearselection()
)
)
on auto_chk changed state do
(
auto_group = state
)
on grp_bot pressed do
(
if my_objs.count != 0 then
(
rengroup()
)
)
on sevendeserts_auto_group close do
(
try(deleteAllChangeHandlers id:#sevendeserts_auto_group_handler)catch()
)
on grp_chk changed state do
(
clearselection()
if state then
(
when select $* changes id:#sevendeserts_auto_group_handler obj do
(
newname_arr = #()
updatemylist()
)
)
else
(
deleteAllChangeHandlers id:#sevendeserts_auto_group_handler
)
)
)
createdialog sevendeserts_auto_group
this script is not bug proof though.. sorry...
but as long as you get the grips on how to use it, all will be ok...
so here's how to use it..
press the ENABLE Button
set the LIMIT. the spinner is the limit of objects to be selected before the autogrouping executes.
select a non-grouped object (if its inside a group, it wont be added to the list)
select the second up to the Nth object. Where the Nth object if is your limit.
note: right now, the script only checks the first object selected to see if its inside a group, so just be careful when selecting objects because that are already grouped. (im still gonna fix this later on.. sorry..
now if the limit is reached, it will rename your objects, thus auto group them
I hope this helps! just post here if you need some modifications... i also inserted some comments, so that you could try and understand how the script works... :thumbsup:
CGTalk Moderation
04-05-2005, 07:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.