dotNet + MXS

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Search this Thread Display Modes
  11 November 2007
Yes Please. I have a maxscript file which I'm making with as much .net as humanely possible in one script as I learn so that I have a clipboard to copy paste code snipets from and reference.

A community effort would be very useful since .net is very very sparsely documented in the help and translating C# into maxscript syntax is for me a trial and error process.
 
  12 December 2007
Has anyone gotten something like a contextual menu to work?

I can do something like:
contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"


But when it comes to creating it, I am unsure how to do that

contextmenu.Show(trackview,arg.location)


CE
__________________
Christopher Evans
 
  12 December 2007
Originally Posted by Anubis: Has anyone gotten something like a contextual menu to work?

I can do something like:
contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"


But when it comes to creating it, I am unsure how to do that

contextmenu.Show(trackview,arg.location)

A .NET Forms ContextMenu can only be shown over a .NET Forms control. Is trackview a .NET Forms control ?
__________________
 
  12 December 2007
I have this working, but I don't know how to get the selected item back.. will update when i figure it out.

on tv nodeMouseClick arg do
   (
       if arg.button == tv.mousebuttons.right then
      (
    	   contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"
    	   contextMenu.MenuItems.Add("Select all children")
    	   contextMenu.MenuItems.Add("Expand branches")
    	   pointTest = (dotNetObject "System.Drawing.Point" arg.x arg.y)
    	   contextmenu.Show tv pointTest
       )
   )

__________________
Christopher Evans
 
  12 December 2007
Got it with some help from my friend MarcoK!

fn OnClick sender args =
   (
     --print sender.Text
     case sender.Text of
     (
 	 "Expand branches": if tv.selectedNode != undefined then tv.selectedNode.ExpandAll()
     )
   )	
   
   on tv nodeMouseClick arg do
   (
     if arg.button == tv.mousebuttons.right then
     (
 	 contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"
 	 contextMenu.MenuItems.Clear()
 	 dotnet.addeventhandler (contextMenu.MenuItems.Add("Select all children")) "Click" OnClick
 	 dotnet.addeventhandler (contextMenu.MenuItems.Add("Expand branches")) "Click" OnClick
 	 pointTest = (dotNetObject "System.Drawing.Point" arg.x arg.y)
 	 contextmenu.Show tv pointTest
     )
   )
__________________
Christopher Evans
 
  12 December 2007
I finally went on and picked up on dotnet. It's not as hard as I thought
But I do have a refresh problem. I do an label edit and with the "AfterLabelEdit" eventhandler I update the listview i have. The problem I have is that
listview.items.clear() works but appearantly not for the label that was edited...!?

I create an extra refresh button and after pressing that it does work... The edited label simply renames an object. It looks like after renaming the script is faster to update the labels than max with renaming the object... any suggestions?

Also, is listview the right way to go when I want to also edit the other fields in a row? It looks like I can't but maybe I'm missing something?

Thanx!
-Johan
__________________
Online: LinkedIn
 
  12 December 2007
Originally Posted by JHN: I finally went on and picked up on dotnet. It's not as hard as I thought
But I do have a refresh problem. I do an label edit and with the "AfterLabelEdit" eventhandler I update the listview i have. The problem I have is that
listview.items.clear() works but appearantly not for the label that was edited...!?

I create an extra refresh button and after pressing that it does work... The edited label simply renames an object. It looks like after renaming the script is faster to update the labels than max with renaming the object... any suggestions?

Also, is listview the right way to go when I want to also edit the other fields in a row? It looks like I can't but maybe I'm missing something?

Thanx!
-Johan
For the label edit, I don't have an immediate solution...as for editing the other columns, you can't do it...well actually there is a hack, but I don't think we have enough access into dotnet via maxscript to get it to work.

The listview only allows for the editing of the first column. If you want to update the other columns, I suggest having a look at one of the grids. That should provide you with the ability to edit the cells.

I've been poking at the idea of writting my user interfaces in Java and using the COM access to send commands back to Max. I know the COM part works, but I've not had much time to look into the rest...but this is for a very particular idea...

Shane
__________________
If it's worth doing, it's worth scripting
Don't wish for this to be eaiser, wish for you to better
 
  12 December 2007
To edit the other fields you can get the placment of the mouse over the field and determine which it is. Then move and editText field to that location for the user to imput information into.

A hack but it works.
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Originally Posted by PEN: To edit the other fields you can get the placment of the mouse over the field and determine which it is. Then move and editText field to that location for the user to imput information into.

A hack but it works.
How do you get a reference to the editfield? Do you create own? How do you place it within the control??

All the code I've seen that does this seems to rely on obtaining window handles...?!?

Shane
__________________
If it's worth doing, it's worth scripting
Don't wish for this to be eaiser, wish for you to better
 
  12 December 2007
Hi Paul / Shane, thanks for that I will look into it! If it isn't what I want or too much of a hack, which datagrid object would you suggest? The thing I need is almost like the new max2008 scene explorer.

Here's a script snippet, too demonstrate that the label is not updating.. any suggestions are welcome!

http://scripts.subd.nl/?f=JHN_dotnetCamList.ms

Create some camera's, run the script. Rename camera via label by clicking a label and wait a sec. Then edit and hit enter or click outside. The object gets renamed properly, the list gets updated and the renamed object moves to the right location. Although the labelplace where the object was doesn't seem to follow along... bit hard to exlpain, please have a look.

Cheers,
-Johan

(I'll be gone for 2 days so if I don't respond it's not because I don't care, cause I do )
__________________
Online: LinkedIn
 
  12 December 2007
I have been using "system.IO.file" for managing files how ever I'm stuck on setting permissions on a file and how to set it to readOnly. Any one know where I should be looking?
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Oh and does any one know where I can down load the .net library from MSDN so speed up searches?
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Originally Posted by PEN: I have been using "system.IO.file" for managing files how ever I'm stuck on setting permissions on a file and how to set it to readOnly. Any one know where I should be looking?
You'll have to forgive the code, I pulled it directly from the MSN docs, but
File.SetAttributes(path, File.GetAttributes(path) Or FileAttributes.ReadOnly) 
should be able to set the attribute
and
If (File.GetAttributes(path) And FileAttributes.ReadOnly) = FileAttributes.ReadOnlyThen
should return true if the file is readonly.

Shane
__________________
If it's worth doing, it's worth scripting
Don't wish for this to be eaiser, wish for you to better
 
  12 December 2007
Originally Posted by PEN: Oh and does any one know where I can down load the .net library from MSDN so speed up searches?
I know a version comes with Visual Studio, it's what I use. If someone can tell me if I'm allowed to "upload" it here, I will.

Shane
__________________
If it's worth doing, it's worth scripting
Don't wish for this to be eaiser, wish for you to better
 
  12 December 2007
I'll have a poke, thanks.
__________________
Paul Neale
http://paulneale.com
 
reply share thread



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:27 PM.


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