Need help translating a little maxscript to c++

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2011
[solved] Bloated scenes eats ram

EDIT:
My original question was what's posted below,
it quickly turned out that there was a easier way to solve this directly with maxscript,
so I've changed the topic to reflect this.
I've also kept the original post just for reference.



Hi,
I need to ask for some help, I have a maxscript that fixes a bug in our scenes,
I'd like to have it into c++, the problem is that I've never worked with this type of thing before, only meshes and materials in c++.

So I'm asking for some help on translating this into c++.
I've got all the framework done for the plugin itself,
it's just the code below I need help with.

If you want to help, then I appreciate it!

Thanks in advance.

The script that needs translation is the following:


 trackIndex = 1
 m = trackViewNodes[trackIndex]
 disableSceneRedraw()
 undo off
 (
 	while (m != undefined) do
 	(
 		ct = numNoteTracks m
 		id = ct
 		for i = 1 to ct do
 		(
 			tr = getNoteTrack m id
 			deleteNoteTrack m tr
 			id = id - 1
 			ith = mod i 200
 		)
 		trackIndex = trackIndex + 1
 		m = trackViewNodes[trackIndex]
 	)
 )
 enableSceneRedraw()
 messagebox "Done!"
 
__________________
http://stigatle.no

Last edited by stigatle : 09 September 2011 at 05:03 AM. Reason: changing to reflect changes in thread
 
  09 September 2011
Originally Posted by stigatle:

  trackIndex = 1
  m = trackViewNodes[trackIndex]
  disableSceneRedraw()
  undo off
  (
  	while (m != undefined) do
  	(
  		ct = numNoteTracks m
  		id = ct
  		for i = 1 to ct do
  		(
  			tr = getNoteTrack m id
  			deleteNoteTrack m tr
  			id = id - 1
  			ith = mod i 200
  		)
  		trackIndex = trackIndex + 1
  		m = trackViewNodes[trackIndex]
  	)
  )
  enableSceneRedraw()
  messagebox "Done!"
  


is it some sort of tangled way to delete all notetracks in the scene or anything more than that?
 
  09 September 2011
yes, it's for deleting all of them,
then problem is following our scenes, when merging and so on,
only way to get rid of them is by deleting them.
Autodesk support gave me the above script.

But it can sit there for over 24hrs trying to delete the tracks.

My hope was that it would be faster in c++.

our current scene has 32.000 note tracks, and each time I save it it grows.
and it eats crazy amounts of RAM, and also a scene with a cube takes over 130mb because of the tracks.

I can provide a sample scene if needed.
__________________
http://stigatle.no
 
  09 September 2011
Originally Posted by stigatle: yes, it's for deleting all of them,
then problem is following our scenes, when merging and so on,
only way to get rid of them is by deleting them.
Autodesk support gave me the above script.

But it can sit there for over 24hrs trying to delete the tracks.

My hope was that it would be faster in c++.

our current scene has 32.000 note tracks, and each time I save it it grows.
and it eats crazy amounts of RAM, and also a scene with a cube takes over 130mb because of the tracks.

I can provide a sample scene if needed.


sometimes people in Autodesk support has no idea about the matter of an issue.
to delete all notetracks do:

 fn deleteAllNoteTracks = 
 (
 	for nt in (getClassInstances DefNoteTrack asTrackViewPick:on) do
 	(
 		while (numNoteTracks nt.client) > 0 do deleteNoteTrack nt.client (getNoteTrack nt.client 1)
 	)
 )
 


it has to delete 32,000 tracks for ... let me guess... 0.7 sec maybe

in c++ it's much easier... see avg_dlx.cpp and extclass.cpp in MAX SDK as samples how to do it.
 
  09 September 2011
thank you, I will give this a try when I get home (I'm on my way out for a motorcycle ride), I'll let you know how it goes.

thanks for helping!
__________________
http://stigatle.no
 
  09 September 2011
Originally Posted by stigatle: thank you, I will give this a try when I get home (I'm on my way out for a motorcycle ride), I'll let you know how it goes.

thanks for helping!


wow! you are ridding bike and reading the forum... it's the great sample of a real PRO!

Last edited by denisT : 09 September 2011 at 02:50 PM.
 
  09 September 2011
3dsmax 2012 x64.
I get this error:
-- Error occurred in deleteAllNoteTracks(); filename: C:\Development\maxscripts\scripts\; position: 91; line: 3
--  Frame:
--   DefNoteTrack: undefined
-- Type error: getClassInstances requires MAXClass, got: undefined
__________________
http://stigatle.no
 
  09 September 2011
Originally Posted by stigatle: 3dsmax 2012 x64.
I get this error:
-- Error occurred in deleteAllNoteTracks(); filename: C:\Development\maxscripts\scripts\; position: 91; line: 3
  --  Frame:
  --   DefNoteTrack: undefined
  -- Type error: getClassInstances requires MAXClass, got: undefined
  


there are many stupid bugs in max... there is one of them.
you have to force registering the DefNoteTrack class...
the way of doing it from mxs is:

 (notetrack "").classid
 

after calling this magic spell you will get the DefNoteTrack class

so the delete all tracks function has to be:

fn deleteAllNoteTracks = 
(
	if DefNoteTrack == undefined do (notetrack "").classid
	for nt in (getClassInstances DefNoteTrack asTrackViewPick:on) do
	(
		while (numNoteTracks nt.client) > 0 do deleteNoteTrack nt.client (getNoteTrack nt.client 1)
	)
)

Last edited by denisT : 09 September 2011 at 05:08 PM.
 
  09 September 2011
that did make it run, but on my comp it still takes so long that I cancelled (it maxed my ram), I do not have too much ram on my computer at home..

I've uploaded the file here:

http://stigatle.net/uploads/filewithbug.zip

Ignore the missing maps etc, there's just a cube in there, nothing else.
If you expand the trackview, and look at the tracks there you will find the thousands of note tracks.

Please give the script a try on the scene, I'd like to know how it works on your end.
__________________
http://stigatle.no
 
  09 September 2011
Originally Posted by stigatle: I've uploaded the file here:

http://stigatle.net/uploads/filewithbug.zip



i don't see any note track here. can you save file for max 2010... i don't have debugger for 2012
 
  09 September 2011
You can grab the file here:
http://stigatle.net/uploads/filewithbug2010.zip

added a screenshot of trackview so that you see where the note tracks are located.

thanks again!
__________________
http://stigatle.no

Last edited by stigatle : 09 September 2011 at 06:43 PM.
 
  09 September 2011
in your sample file only Max_MotionClip_Manager has 8,305,440 note tracks! How did you do it?
 
  09 September 2011
we have no clue as to what is causing it (and never got a answer from autodesk support as to why it happens), it also seems to multiply on each save.
And it follows the scene when we merge and so on, kinda acts like a virus in our scenes.

It also brings down the renderfarm due to the RAM it occupies etc, causing major havoc.
__________________
http://stigatle.no
 
  09 September 2011
Originally Posted by stigatle: we have no clue as to what is causing it (and never got a answer from autodesk support as to why it happens), it also seems to multiply on each save.
And it follows the scene when we merge and so on, kinda acts like a virus in our scenes.

It also brings down the renderfarm due to the RAM it occupies etc, causing major havoc.


i will try to fix it because it's very interesting for me. i haven't seen it before.
but if you find what causes the problem please let me know.

the number of note tracks is a problem but not the issue. the problem is that all these tracks have very weird referencing...
 
  09 September 2011
would be awesome if you could help on the solution.
As I stated it's very important to us to find a way to fix it.

We've had this problem before, but the script could handle it at the time, but now it's grown to such a massive amount of notes that it has major problems with fixing it.

I got some help earlier today from a colleague of mine with implementing it as c++,
we almost had it when I had to leave work today, but we'll continue on it tomorrow morning to see if we can make it run.

I will obviously post any information regarding this here, because it might help someone else later.
__________________
http://stigatle.no

Last edited by stigatle : 09 September 2011 at 07:40 PM.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:37 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.