CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 02-01-2013, 09:22 AM   #16
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
Quote:
Originally Posted by denisT
the solution of what?


I may have misunderstood the topic but it seems that you found a better way to organize your script, including the macro inside the struct.
 
Old 02-01-2013, 01:36 PM   #17
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
so... let's continue:
Code:
global HelloWorld ( struct HelloWorldStruct ( private pos = [800,200], size = [200,40], opened = off, public dialog = ( rollout dialog "Hello World" ( on dialog open do HelloWorld.open() on dialog close do HelloWorld.close() ) ), fn isOpen = (iskindof dialog RolloutClass and opened), fn open = ( opened = on createdialog dialog pos:pos size:size ), fn close = ( opened = off destroydialog dialog ), fn toggle = if isOpen() then close() else open(), action = ( macroScript Macro_HelloWorld category:"HelloWorld" tooltip:"Hello World" buttonText:"Hi WORLD" silentErrors:off ( local d fn enabled = isstruct (d = HelloWorld) on execute do if enabled() do d.toggle() ) ), on create do ( if isstruct HelloWorld do HelloWorld.close() ) ) HelloWorld = HelloWorldStruct() ok )


try to execute the code. the code automatically defines the macro. you can go to Customize User Interface... and in category HelloWorld find "Hello World" macros. Make a button, try to press it... but try to restart the max...
 
Old 02-01-2013, 01:47 PM   #18
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
... the bad news is the button doesn't work anymore. because nothing loaded our structure.
the good new is it doesn't break anything. because i check the structure existence before execute the macro.

let's save the code as MS file in any auto-loading by max directory. let's save it as ...max\scripts\startup\HelloWorld\HelloWorld.ms
and restart max...
 
Old 02-01-2013, 01:52 PM   #19
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
... now you see that button works.
the question is where is really our macros placed? the answer is simple. in the user's macroscripts directory.
and it load before our structure, but our structure successfully redefine it on startup. (remember this fact. you will use it later).

our button works as toggle. how is about to make works as ON/OFF (if dialog open it's checked, if not - not checked)

... to be continued
 
Old 02-01-2013, 01:58 PM   #20
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
it's so easy because i already have everything for that... we need just add to lines:
Code:
global HelloWorld ( struct HelloWorldStruct ( private pos = [800,200], size = [200,40], opened = off, public dialog = ( rollout dialog "Hello World" ( on dialog open do HelloWorld.open() on dialog close do HelloWorld.close() ) ), fn isOpen = (iskindof dialog RolloutClass and opened), fn open = ( opened = on createdialog dialog pos:pos size:size ), fn close = ( opened = off destroydialog dialog ), fn toggle = if isOpen() then close() else open(), action = ( macroScript Macro_HelloWorld category:"HelloWorld" tooltip:"Hello World" buttonText:"Hi WORLD" silentErrors:off ( local d fn enabled = isstruct (d = HelloWorld) on isEnabled do enabled() on isChecked do enabled() and d.isOpen() on execute do if enabled() do d.toggle() ) ), on create do ( if isstruct HelloWorld do HelloWorld.close() ) ) HelloWorld = HelloWorldStruct() ok )
 
Old 02-01-2013, 02:00 PM   #21
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
the button works but if we open the dialog from script or close the dialog manually the button state doesn't change. hmm... what can we do? ... be continued
 
Old 02-01-2013, 05:55 PM   #22
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
to make it works right we only need to add updateToolbarButtons() to open and close functions...
Code:
global HelloWorld ( struct HelloWorldStruct ( private pos = [800,200], size = [200,40], opened = off, public dialog = ( rollout dialog "Hello World" ( on dialog open do HelloWorld.open() on dialog close do HelloWorld.close() ) ), fn isOpen = (iskindof dialog RolloutClass and opened), fn open = ( opened = on createdialog dialog pos:pos size:size updateToolbarButtons() ), fn close = ( opened = off destroydialog dialog updateToolbarButtons() ), fn toggle = if isOpen() then close() else open(), action = ( macroScript Macro_HelloWorld category:"HelloWorld" tooltip:"Hello World" buttonText:"Hi WORLD" silentErrors:off ( local d fn enabled = isstruct (d = HelloWorld) on isEnabled do enabled() on isChecked do enabled() and d.isOpen() on execute do if enabled() do d.toggle() ) ), on create do ( if isstruct HelloWorld do HelloWorld.close() ) ) HelloWorld = HelloWorldStruct() updateToolbarButtons() ok )
 
Old 02-01-2013, 06:02 PM   #23
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
now the question is ... why do i put the macros definition inside the structure if i can leave it outside but still in the same file? ... be continued
 
Old 02-01-2013, 06:53 PM   #24
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
What a teasing!!
 
Old 02-01-2013, 06:56 PM   #25
DaveWortley
<database error>
 
DaveWortley's Avatar
portfolio
David Wortley
Technical Director
London, United Kingdom
 
Join Date: Dec 2004
Posts: 1,845
Send a message via MSN to DaveWortley
You lost me long ago Denis, I can see what you're doing it and why, but I've got a setup here where all our scripts are in a central repository as script files not macros. Then we have an interface which allows you to quickly make a button on the toolbar which just fires a fileIn to the needed script file.

I'm finding the centralised database a much better system as I can update and edit scripts and everyone has the latest version.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 02-01-2013, 08:14 PM   #26
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
Quote:
Originally Posted by DaveWortley
You lost me long ago Denis, I can see what you're doing it and why, but I've got a setup here where all our scripts are in a central repository as script files not macros. Then we have an interface which allows you to quickly make a button on the toolbar which just fires a fileIn to the needed script file.

i don't want to say that macros in structures is only right way to organize tool distribution.
i just want to show how to do it.
Quote:
Originally Posted by DaveWortley
I'm finding the centralised database a much better system as I can update and edit scripts and everyone has the latest version.

the centralised database is what i have. the user just has to add my root directory as a 3-rd Party Path to get everything (plugins, dll, scripts, startup, icons, etc.) automatically loaded with max. and of course user can place the root directory anywhere he wants.
 
Old 02-02-2013, 05:13 PM   #27
PEN
R&D/Technical Director
 
PEN's Avatar
portfolio
Paul Neale
PEN Productions
Canada
 
Join Date: Jun 2002
Posts: 7,416
Nice Denis, hadn't even thought of going down that sort of root.
__________________
Paul Neale
http://paulneale.com
 
Old 02-03-2013, 01:53 PM   #28
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,424
Send a message via ICQ to denisT
and now finally... why i like to add macros to structures and use it as one setup module.
it makes very easy and clean the adding menu items:
Code:
global HelloWorld ( struct HelloWorldStruct ( private pos = [800,200], size = [200,20], menuname = "Hello &World", opened = off, public dialog = ( rollout dialog "Hello World" ( on dialog open do HelloWorld.open() on dialog close do HelloWorld.close() ) ), fn isOpen = (iskindof dialog RolloutClass and opened), fn open = ( opened = on createdialog dialog pos:pos width:size.x height:size.y updateToolbarButtons() ), fn close = ( opened = off destroydialog dialog updateToolbarButtons() ), fn toggle = if isOpen() then close() else open(), action = ( macroScript Macro_HelloWorld category:"HelloWorld" tooltip:"Hello World" buttonText:"Hi WORLD" silentErrors:off ( local d fn enabled = isstruct (d = HelloWorld) on isEnabled do enabled() on isChecked do enabled() and d.isOpen() on execute do if enabled() do d.toggle() ) ), fn createMenu = ( local menu = menuMan.getMainMenuBar() local n = 0, m for k=1 to menu.numitems() where (m = menu.getitem k).getTitle() == menuname do exit with menu.removeitem m for k=1 to menu.numitems() while n == 0 where (m = menu.getitem k).getTitle() == "&Help" do n = k if n != 0 do ( m = menuMan.createMenu menuname menu.additem (menuMan.createSubMenuItem menuname m) n a = menuMan.createActionItem "Macro_HelloWorld" "HelloWorld" a.setUseCustomTitle on a.setTitle "Display" m.addItem a 1 ) menuMan.updateMenuBar() ), on create do ( if isstruct HelloWorld do HelloWorld.close() createMenu() updateToolbarButtons() ) ) HelloWorld = HelloWorldStruct() ok )
 
Old 02-03-2013, 03:27 PM   #29
DaveWortley
<database error>
 
DaveWortley's Avatar
portfolio
David Wortley
Technical Director
London, United Kingdom
 
Join Date: Dec 2004
Posts: 1,845
Send a message via MSN to DaveWortley
Nice!...............
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 02-03-2013, 03:27 PM   #30
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:00 AM.


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