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 04-06-2013, 12:14 AM   #16
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
Quote:
Originally Posted by Mambo4
what about

Code:
[...] local owner = if owner != undefined do owner [...] on create do ( destroy() rollouts.owner = this )


the latter part seems to set a .owner property to the struct
but what's the first part do? seems odd to "do" a property...


that's also the trick that belongs to me... this little hack prevents the property from overwriting at the time of a rollout creating.
 
Old 04-07-2013, 08:22 AM   #17
HuaMuLan
o(︶︿︶)o
portfolio
Hua MuLan
Shanghai, China
 
Join Date: Sep 2008
Posts: 114
Send a message via MSN to HuaMuLan
Quote:
Originally Posted by denisT
that's also the trick that belongs to me... this little hack prevents the property from overwriting at the time of a rollout creating.

I can't clearly understand it. Any example?
Quote:
Originally Posted by denisT
so the modern paradigm for a tool is "one tool - one global"

usually, I tend to construct a definite file structure to manage my tool files.
Like
init.ms at the top of my file structure maybe with only two lines in it.
Code:
global myTool_path = getFilenamePath(getSourceFileName()); fileIn "FileStructrue/tool.ms"

under FileStructrue folder there is tool.ms with many include like
Code:
include "FileStructrue/lib/UIlib.ms" include "FileStructrue/lib/Functionlib.ms" .....

I like the idear "one tool - one global". But I also want to keep my fileStucture to keep things clear. Is there a general pratical way to do this? note that the variable "myTool_path" in the init.ms is important for most of my tool is drop-in tool.
 
Old 04-07-2013, 09:26 AM   #18
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
Quote:
Originally Posted by HuaMuLan
I can't clearly understand it. Any example?

my snippet is a sample. try to remove the owner definition and check the difference
Quote:
usually, I tend to construct a definite file structure to manage my tool files.
Like
init.ms at the top of my file structure maybe with only two lines in it.
Code:
global myTool_path = getFilenamePath(getSourceFileName()); fileIn "FileStructrue/tool.ms"

under FileStructrue folder there is tool.ms with many include like
Code:
include "FileStructrue/lib/UIlib.ms" include "FileStructrue/lib/Functionlib.ms" .....


i never use include in my max scripting. i use filein only in macroscripts to call main code.
 
Old 04-08-2013, 08:09 AM   #19
HuaMuLan
o(︶︿︶)o
portfolio
Hua MuLan
Shanghai, China
 
Join Date: Sep 2008
Posts: 114
Send a message via MSN to HuaMuLan
That's odd. I comment out parts of the code like this
Code:
local owner -- = if owner != undefined do owner

My listener says
Code:
>> MAXScript Rollout Handler Exception: -- Unknown property: "dialogWidth" in undefined << >> MAXScript Rollout Handler Exception: -- Unknown property: "dialogWidth" in undefined <<

According to the code logic, if owner is undefined "do owner" will not execute. So logically, there are no difference before and after I comment out these codes.
I am lost. Ha~.
 
Old 04-09-2013, 12:59 PM   #20
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
Quote:
Originally Posted by denisT
here is it:
Code:
global GeneralSceneOps ( struct GeneralSceneStruct ( fn destroy = try(closeRolloutFloater GeneralSceneOps.dialog) catch(), title = "General Scene Helpers", dialogWidth = 250, dialogHeight = 400, dialog, MatStruct = ( struct MatStruct (material, slot) ), ObjectRollout = rollout ObjectRollout "Objects" ( local owner = if owner != undefined do owner button deleteall_bt "Delete All Objects" align:#left width:(owner.dialogWidth - 30) offset:[-5,0] on deleteall_bt pressed do undo "Delete All" on ( format ">>> %\n" owner delete objects ) ), materials = #(), MaterialRollout = rollout MaterialRollout "Materials" ( local owner = if owner != undefined do owner button collectmats_bt "Collect Editor Materials" align:#left width:(owner.dialogWidth - 30) offset:[-5,0] on collectmats_bt pressed do ( owner.materials = for k=1 to 24 collect (owner.MatStruct (medit.GetTopMtlSlot k) k) format "mats: %\n" owner.materials ) ), rollouts = #(ObjectRollout, MaterialRollout), fn show = ( destroy() dialog = newRolloutFloater title dialogWidth dialogHeight for r in rollouts do addRollout r dialog ), on create do ( destroy() rollouts.owner = this ) ) GeneralSceneOps = GeneralSceneStruct() ok ) GeneralSceneOps.show()

this snippet mostly shows my style of tool design. don't try to find a sense in the button functions


What about this error ?
It seems that you cannot use nested structs with this tool design. Try this:
Code:
global genericGlobal ( struct genericTool ( Element = ( struct Element ( member ) ), ElementArray = ( struct ElementArray ( objs = #(Element) ) ), testArray = #(), on create do ( print (ElementArray()); ) ) genericTool(); )


Denis, have you ever had this kind of problems ?
 
Old 04-09-2013, 02:03 PM   #21
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
Quote:
Originally Posted by feranti
What about this error ?
It seems that you cannot use nested structs with this tool design. Try this:
Code:
global genericGlobal ( struct genericTool ( Element = ( struct Element ( member ) ), ElementArray = ( struct ElementArray ( objs = #(Element) ) ), testArray = #(), on create do ( print (ElementArray()); ) ) genericTool(); )


Denis, have you ever had this kind of problems ?

there is no problem in your sample. it looks just as wrong definition for me. here is how i would do the same:
Code:
global genericGlobal ( struct genericTool ( Element = ( struct Element ( member ) ), ElementArray = ( struct ElementArray ( objs = #() ) ), testArray = #(), on create do ( print (ElementArray objs:#(Element)); ) ) genericTool(); )

but it doesn't make sense for me to have a struct definition (Element) as array item instead of have its instance.
 
Old 04-09-2013, 03:13 PM   #22
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
Quote:
but it doesn't make sense for me to have a struct definition (Element) as array item instead of have its instance.

In that simple case, I agree with you. It was only a short snippet to highlight the nested structs design. The array is a bad idea there because it often starts empty...

This following snippet might be more the problematic case:
Code:
global genericGlobal ( struct genericTool ( Element = ( struct Element (member) ), NestedElement = ( struct NestedElement ( nested = Element(), anotherMember ) ), testArray = #(), on create do ( local test = NestedElement(); print test ) ) genericTool(); )


This kind of nested definition can occur often enough, in my opinion.

I wanted to know if there was any workaround for that. This kind of structure definition works when the struct are not nested under one single struct.

Edit: Obviously, you could fill the "nested" property each time you create one instance of the NestedElement() struct but it is a pain...

Last edited by feranti : 04-09-2013 at 03:16 PM.
 
Old 04-09-2013, 04:14 PM   #23
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
here is a workaround:
Code:
global genericGlobal ( struct genericTool ( NestedElement = ( struct NestedElement ( Element = ( struct Element (member) ), nested = Element(), anotherMember ) ), testArray = #(), on create do ( local test = NestedElement() print test ) ) genericTool() )
 
Old 04-09-2013, 04:23 PM   #24
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
Ok... I still think it is quite dirty because you need to declare the Element struct as many times as you want to nest it into another struct but... it is a workaround !
 
Old 04-09-2013, 04:38 PM   #25
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
Quote:
Originally Posted by feranti
Ok... I still think it is quite dirty because you need to declare the Element struct as many times as you want to nest it into another struct but... it is a workaround !

i'm not sure that you clear understand how structs and struct definitions works...
there is another way to do want you want:
Code:
global genericGlobal ( struct Element (member) struct genericTool ( NestedElement = ( struct NestedElement ( nested = Element(), anotherMember ) ) ) genericTool() )

use nested structs where they work...
 
Old 04-09-2013, 05:07 PM   #26
feranti
Frequenter
Antoine Ferrieux
Paris, France
 
Join Date: Apr 2008
Posts: 208
We agree on that last one !
I ended up with that, too.

At first, I was trying to declare all my structs inside the genericTool struct because I don't use (at the moment...) the big global encapsulating brackets design (cf. my posts earlier).
So, to avoid having my structs declared as global, I was looking for a way to embed their declarations in my tool struct.
Then I hit this nested definition problem...

Anyways, thanks for the quick answers Denis
I think it is time to convert myself to the global encapsulation religion
 
Old 04-09-2013, 05:07 PM   #27
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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 07:12 AM.


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