Notifications
Clear all

[Closed] Need help translating a little maxscript to c++

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!"
 
24 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

is it some sort of tangled way to delete all notetracks in the scene or anything more than that?

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.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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.

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!

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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

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

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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)
	)
)

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.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i don’t see any note track here. can you save file for max 2010… i don’t have debugger for 2012

You can grab the file here:
[u] http://stigatle.net/uploads/filewithbug2010.zip [/u]

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

thanks again!

in your sample file only Max_MotionClip_Manager has 8,305,440 note tracks! How did you do it?

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.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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…

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.

I think is an old bug related to biped

In my case I have biped removed, and the notes seems trapped inside a missing track

deleteTrackViewController to remove the whole track, should work,
if nothing relevant… in that motion mixer track

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

yes… i’m looking in this direction. i just want to keep as much data as possible

Page 1 / 2