- Type error: Call needs function or class, got: undefined PLEASE HELP!!!!

I get this error, if even BitmapLister is global! Please HELP!!!!
Here is the script:

macroScript Bitmaps
category: "artrender"
(  	
	try(destroydialog ::BitmapLister)catch()
	bitmaps=#()
 
 
	GLOBAL BitmapLister
 
 
 
	cur_obj_selection=#()
	BitmapLister_iso_x = getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" as integer
	BitmapLister_iso_y = getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" as integer
	BitmapLister_size_h = (if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" as integer)) == 0 then 324 else tmp)
	BitmapLister_size_w = (if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" as integer)) == 0 then 152 else tmp)
	numBitmaps = 0
 
  function enable_event = (
 
  callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent
 
 )
  function disable_event = (
 
 
   callbacks.RemoveScripts #selectionSetChanged id:#m3dLearnEvent
 
 )
 ------------------------------
 
 function check_selection = (
  this_sel_count = (selection as array).count
  BitmapLister.lbl_num_picked.text = "num picked: " + (this_sel_count as string)
 
  )
 
 
 
rollout BitmapLister "Maps" width:231 height:65
(
 
 
label lbl_num_picked "Num Picked: 0" pos:[380,20] width:62 height:40 
 
 
dotNetControl lv "System.Windows.Forms.ListView" width:657 height:200 pos:[5,100]
 
 
 
 
 
 on BitmapLister close do (
  			disable_event()
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" ((GetDialogPos BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" ((GetDialogPos BitmapLister).y as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" ((GetDialogSize BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" ((GetDialogSize BitmapLister).y as string)
 
 
 )
 
 on BitmapLister open do
 (
   check_selection()
   enable_event()
  )
)
createdialog BitmapLister pos:[BitmapLister_iso_x,BitmapLister_iso_y] height:(BitmapLister_size_h) width:(BitmapLister_size_w) style:#(#style_resizing,#style_sysmenu,#style_titlebar)
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

I'll worry about your

I'll worry about your check_selection function.
It s'd be visible for callbacks.addScript().
Also maybe is good to make it more robust:

fn check_selection = 
(
if isKindOf BitmapLister RolloutClass do (
	BitmapLister.lbl_num_picked.text = \
	" Num Picked: " + (selection.count as string)
	fillInList BitmapLister.lv ---- ?...
)
)

And I'll suggets to move functions fillInList and initListView inside BitmapLister rollout, and then the last command in those function will become:
BitmapLister.fillInList BitmapLister.lv
i.e.:

if isKindOf BitmapLister RolloutClass do (
	BitmapLister.lbl_num_picked.text = \
	" Num Picked: " + (selection.count as string)
	BitmapLister.fillInList BitmapLister.lv
)

my recent MAXScripts RSS (archive here)

barigazy's picture

Yep. you are right. No need

Yep. you are right. No need to be outside roll definition.

barigazy

barigazy's picture

example

(  	
	try(destroydialog ::BitmapLister)catch()
	local bitmaps=#(), cur_obj_selection=#(), numBitmaps = 0
	local BitmapLister_iso_x = 10 --getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" as integer
	local BitmapLister_iso_y = 110 --getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" as integer
	local BitmapLister_size_h = 230 --(if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" as integer)) == 0 then 324 else tmp)
	local BitmapLister_size_w = 310 --(if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" as integer)) == 0 then 152 else tmp)
 
	fn initListView lv =
	(
		lv.fullRowSelect = lv.gridLines = true
		lv.View = (dotNetClass "View").Details
		layout_def = #("Object Name", "Object Class", "Wirecolor")
		for i in layout_def do lv.Columns.add i 100
	)	
	fn fillInList lv = if selection.count != 0 do
	(
		local selectionNames = #() --array to collect the list items
		for o in selection do
		(
			li = dotNetObject "ListViewItem" o.name
			sub_li = li.SubItems.add ((classof o) as string)
			sub_li = li.SubItems.add (o.wirecolor as string)
			append selectionNames li
		)
		lv.Items.AddRange selectionNames
	)
	fn enable_event = (callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent)
	fn disable_event = callbacks.RemoveScripts #selectionSetChanged id:#m3dLearnEvent
	fn check_selection = 
	(
		this_sel_count = selection.count
		BitmapLister.lbl_num_picked.text = " Num Picked: " + (this_sel_count as string)
		fillInList BitmapLister.lv
	)
 
	rollout BitmapLister "Maps" width:231 height:65
	(
		label lbl_num_picked " Num Picked: 0" pos:[5,5] width:80 height:20 
		dotNetControl lv "ListView" width:300 height:200 pos:[5,30]
		on BitmapLister close do 
		(
			disable_event()
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" ((GetDialogPos BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" ((GetDialogPos BitmapLister).y as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" ((GetDialogSize BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" ((GetDialogSize BitmapLister).y as string)
		)
		on BitmapLister open do 
		(
			initListView BitmapLister.lv
			check_selection() ; disable_event() ; enable_event()
		)
	)
createdialog BitmapLister BitmapLister_size_w BitmapLister_size_h BitmapLister_iso_x BitmapLister_iso_y style:#(#style_resizing,#style_sysmenu,#style_titlebar)
)

barigazy

artrender.info's picture

STILL THE SAME ERROR

I want to thank you for this help! Srry that I disturb you, but I've tried your code at two computers, and it's giving the same error! I've tried to put after this GLOBAL BitmapLister and it does not help also! Please, tell me! The error appears after selecting any object in scene!
Also, restart 3d max (not reset), and try! It may happen that after many times of trying in the same scene, it could start working! this happend to my previous scripts! But they should work even from the start!

AttachmentSize
error.jpg 175.84 KB
barigazy's picture

try now

(	
	global BitmapLister
	global enable_event, disable_event, check_selection
	try(destroydialog BitmapLister)catch()
	local bitmaps=#(), cur_obj_selection=#(), numBitmaps = 0
	local BitmapLister_iso_x = 10 --getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" as integer
	local BitmapLister_iso_y = 110 --getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" as integer
	local BitmapLister_size_h = 230 --(if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" as integer)) == 0 then 324 else tmp)
	local BitmapLister_size_w = 310 --(if (tmp = (getinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" as integer)) == 0 then 152 else tmp)
 
	fn initListView lv =
	(
		lv.fullRowSelect = lv.gridLines = true
		lv.View = (dotNetClass "View").Details
		layout_def = #("Object Name", "Object Class", "Wirecolor")
		for i in layout_def do lv.Columns.add i 100
	)	
	fn fillInList lv = if selection.count != 0 do
	(
		lv.items.clear()
		local selectionNames = #() --array to collect the list items
		for o in selection do
		(
			li = dotNetObject "ListViewItem" o.name
			sub_li = li.SubItems.add ((classof o) as string)
			sub_li = li.SubItems.add (o.wirecolor as string)
			append selectionNames li
		)
		lv.Items.AddRange selectionNames
	)
	fn enable_event = (callbacks.addScript #selectionSetChanged "check_selection()" id:#m3dLearnEvent)
	fn disable_event = callbacks.RemoveScripts #selectionSetChanged id:#m3dLearnEvent
	fn check_selection = 
	(
		this_sel_count = selection.count
		BitmapLister.lbl_num_picked.text = " Num Picked: " + (this_sel_count as string)
		fillInList BitmapLister.lv
	)
 
	rollout BitmapLister "Maps" width:231 height:65
	(
		label lbl_num_picked " Num Picked: 0" pos:[5,5] width:80 height:20 
		dotNetControl lv "ListView" width:300 height:200 pos:[5,30]
		on BitmapLister close do 
		(
			disable_event()
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_x" ((GetDialogPos BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "pos_y" ((GetDialogPos BitmapLister).y as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_w" ((GetDialogSize BitmapLister).x as string)
			setinisetting "$plugcfg\\RacoonScripts.ini" "BitmapLister" "size_h" ((GetDialogSize BitmapLister).y as string)
		)
		on BitmapLister open do 
		(
			disable_event()
			initListView BitmapLister.lv
			check_selection()
			enable_event()
		)
	)
createdialog BitmapLister BitmapLister_size_w BitmapLister_size_h BitmapLister_iso_x BitmapLister_iso_y style:#(#style_resizing,#style_sysmenu,#style_titlebar)
)

barigazy

artrender.info's picture

THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU!

I'M SO HAPPY! THANK YOU, BARIGAZYYYYYYYYYYYYYYYYYYY!

barigazy's picture

:) :) :)

Cheers dude!

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.