Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / "$.name error on node creation"
  RSS 2.0 ATOM  

"$.name error on node creation"
Rate this thread
 
40554
 
Permlink of this thread   Subscribe to this thread
avatar
  • Tushar
  • Posted: 09 March 2010 03:39 PM
  • Total Posts: 20
  • Joined: 19 November 2007 09:20 AM

Hi everybody,
I have created a small script using timer of max rollout clause and DotNet timer. Which I would call on #nodeCreated callback in final script.
It works fine in all the objects creation except when creating objects with .target or bone objects in which next object is automatically created by max.
Like, Target Camera, Target lights, bones etc. (But works with Biped.)

Here’s the code.

-----------max rollout timer-----------
(
rollout rol_ “”
(
timer tim “” interval:1000
on tim tick do
(
toPrint = if $ != undefined then $.name
print toPrint
if toPrint != undefined then tim.active = false
)
)
createDialog rol_ 50 0
-------close the rollout to stop the timer
)
------DotNet timer---------
/*(
global tim
local toPrint
local myFn
fn myFn =
(
toPrint = if $ != undefined then $.name
print toPrint
)
tim = dotNetObject “System.Windows.Forms.Timer”
dotnet.addEventHandler tim “tick” myFn
tim.interval = 1000
tim.start()
--tim.stop()
--copy and paste tim.stop() in listener to stop the time or restart max.
)*/

(I don’t know why attachments are not uploaded. So I have to paste code here.)

Regards,
Tushar



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 13781
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Please see this post for help with attachments.

If you post code, always enclose it in [ code ]...[ /code ] tags (without the spaces) - otherwise the forum display can screw with the code making it impossible to cut’n’paste.

I suspect it’s to do with the creation method (internally) - until the object is fully created it does not have a “name” property, hence the exception.

if $ != undefined then
   
try
      
toPrint = $.name
   
catch
      
(toPrint "Unknown")
print toPrint


Max 4.2 through 2012 (SP2+SAP).
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 1
/img/forum/dark/default_avatar.png

Thanks for info about attachments and enclosing code. Will take care next time.
Much thanks for suggesting the work around.

Author: Tushar

Replied: 21 March 2010 09:01 PM  




   
  Settings Choose Theme color: