ScriptSpot

Forum topic · General Scripting

How to store last subobjectLevel ?

By general_knox · 2011-09-09

Description

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

wow

general_knox · 2011-09-12

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

David

miauu · 2011-09-15

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.

:)

Here the script.Бут, I am

miauu · 2011-09-12

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

nice work

Anubis · 2011-09-13

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!

Attachments

A bit more help

general_knox · 2011-09-12

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 · 2011-09-09

subObjectLevel

(read/write) system global variable