How to store last subobjectLevel ?

Hi,

Ive been using melscript for close to 8 years and Im currently learning maxscript.

I would like to know how to store the currently-used subobject level (1-5) into a variable...It would be used in this fashion:

Suppose user "A" is in subobject level 1 (vertex)... he presses a hotkey ("d"), and he is returned to the top-level....if he presses "d" again, it will go to the last-used subobject level he was previously in, in this case; 1 (vertex).

How would I go about scripting this? I will be able to learn from this post enough so I can manage from then on!

Thanks for your time,

David

Comments

Comment viewing options

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

wow

This is exactly what I wanted to achieve! Thank-you very much...I will study your code and learn from that!

David

miauu's picture

Go to the script thread and

Go to the script thread and read the post #1.
You can uninstall the script because there is built-in max command for that - ctrl+B.

:)

miauu's picture

Here the script.Бут, I am

Here the script.

Instead of using the ini file you can create a dummy and  write the sol to it userproperties, but, I am sure that Anubis can offer you a much better solution. :)

Anubis's picture

nice work

Thanks for the nice words about me :) You done good job so hardly need to harm my brain on this task :) Yep, am too like working with ini files, but how (and when) to store settings is dependent on the case. Maybe for this task one temp global variable is a quite enough?

Well, am a bit busy right now but see some points for improvement, so end with some quick script (attached):

macroscript UndoSubObjectLevel
	category:"Anubis" internalcategory:"Anubis"
	tooltip:"Undo SubObject Level"
	buttonText:"Undo SOL"
(
	if not isKindOf ::LastSubObjectLevel Number do
		::LastSubObjectLevel = 0
 
	fn filtActive = (
		selection.count == 1 and IsSubSelEnabled() and \
		getCommandPanelTaskMode() == #modify and \
		numSubObjectLevels >= LastSubObjectLevel
	)
 
	on isEnabled return filtActive()
	on isVisible return filtActive()
	on execute do (swap LastSubObjectLevel subObjectLevel)
)

I made some restrictions, only those that necessary, to avoid errors. Also used Swap function, so the final functionality is more like "undo-last" subObject level. Im not sure is that follow strictly David request, but lets hope its useful anyway :)

Cheers!

AttachmentSize
undosubobjectlevel.mcr 807 bytes

my recent MAXScripts RSS (archive here)

general_knox's picture

A bit more help

I tried this but it doesnt switch the subObject mode to the int iSub

-- SubObjectModeToggle
-- v1.0

macroScript DaveTools_SubObjectModeToggle
category:"DaveTools"
toolTip:"SubObjectMode Toggle"

global iSub = 0

function DaveTools_SubObjectModeToggle =
(

--print global iSub
if subObjectLevel == 0 and iSub != null then subObjectLevel = iSub
iSub = subObjectLevel
if subObjectLevel != 0 then subObjectLevel = 0
if subObjectLevel != 0 then subObjectLevel = 0
--print global iSub

)-- end - function DaveTools_SubObjectModeToggle

Anubis's picture

subObjectLevel

subObjectLevel (read/write) system global variable

my recent MAXScripts RSS (archive here)

Comment viewing options

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