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
  12 December 2007
easy way to get listview subitem

I been updating my code to use dotNet, and found an easy way to get the index of the subitem clicked

	
  --lv is the DotNetListView object
 
 fn subItemAtMousePos =
 (
  		pos = lv.mousePosition -- screen position
  		pos = lv.PointToClient pos -- position in listview window
  
  		li = lv.getItemAt pos.x pos.y
  
  		si = li.getSubItemAt pos.x pos.y
  		#( li.index , (li.subitems.indexof si) )
 ),
  
 on lv click arg do 
 (
  		theCell = subItemAtMousePos()
  		format "cell index X: % Y: %" theCell[1] theCell[2]
  
 )
 
__________________
ken

my articles and MAXScripts... www.designimage.co.uk
 
  12 December 2007
Do you mean the documentation for the library? If so, I'm pretty sure either the Platform SDK or the .NET SDK docs come with it. I think the .NET SDK actually comes with the platform SDK, so if you get that, you should get a local copy of all the docs.
(The Platform SDK actually got renamed to Windows SDK recently, so check either search term if you don't find it)

RustyKnight, uploading it is a bit big ain't it? 600 or so MB?
__________________


 
  12 December 2007
K another one that I cant sus out from MSDN, "system.dateTime" I want to be able to create a date time of my choosing.

I can use it to get the .now property but I want to set a dateTime from string values that I have. I would like to build it with year, month, day, hour, min, sec values.

Any idea on how I go about that?
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Originally Posted by PEN: K another one that I cant sus out from MSDN, "system.dateTime" I want to be able to create a date time of my choosing.

I can use it to get the .now property but I want to set a dateTime from string values that I have. I would like to build it with year, month, day, hour, min, sec values.

Any idea on how I go about that?

Take a look at all the constructors available for a DateTime value at http://msdn2.microsoft.com/en-us/li...ime(VS.80).aspx. You can build your own date value from these methods.

For example, this example uses the constructor DateTime (Int32, Int32, Int32) (year/month/day):
today = dotNetObject "System.DateTime" 2007 12 17
__________________

Last edited by ypuech : 12 December 2007 at 10:20 PM.
 
  12 December 2007
Originally Posted by PEN: K another one that I cant sus out from MSDN, "system.dateTime" I want to be able to create a date time of my choosing.

I can use it to get the .now property but I want to set a dateTime from string values that I have. I would like to build it with year, month, day, hour, min, sec values.

Any idea on how I go about that?
Hi Pen!

The typical method I would use would be to parse the string to a date value...obviously, the question is how.

I had a quick look at System.DateTime and found a number of parse methods.

Unfourtantly, I don't know how to call static methods from inside max, so I took a look at the constructor values. I found the following constructor that would suit your needs:
Quote: DateTime(year, month, day, hour, minute, second)


And the test code...

 	local dnDateTime = dotNetObject "System.DateTime" 1972 03 08 18 30 0
 	
 	-- prints "8/03/1972 6:30:00 PM" -- Australian
 	format "%\n" (dnDateTime.toString())
 
Hope it helps

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 RustyKnight: I had a quick look at System.DateTime and found a number of parse methods.

Unfourtantly, I don't know how to call static methods from inside max.

The Parse static method (http://msdn2.microsoft.com/en-us/li...d40(VS.80).aspx ) from DateTime can be used like that:

DateTime = dotNetClass "System.DateTime"
date = DateTime.Parse "8/03/1972 6:30:00 PM"
print (date.ToString())


I used "8/03/1972 6:30:00 PM" to reverse the date creation from the previous example.
__________________
 
  12 December 2007
Originally Posted by ypuech: The Parse static method (http://msdn2.microsoft.com/en-us/library/1k1skd40(VS.80).aspx ) from DateTime can be used like that:

DateTime = dotNetClass "System.DateTime"
 date = DateTime.Parse "8/03/1972 6:30:00 PM"
 print (date.ToString())


I used "8/03/1972 6:30:00 PM" to reverse the date creation from the previous example.
DotNetClass!!! *smacks head against brick wall*

So bloody obvious!!

I'm so jelious, you guys get to play with the good stuff. I'm stuck sitting between max 8 and max 9 (32 & 64) and it is driving me crazy...

max 8-9 (32) will talk to activex, max9 (32) and max 9 (64) will talk to dotnet but I need to bridge across max 8 to max 9 (64)...I want to die

note - max9 (64) will talk to activex, but windows 64 does not, by default, seem to include the all important listview control...on our installs any way...

I'm so annoyed I'm even thinking of developing a com server to do my UI work instead...but I think that is just a little over the edge
__________________
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 RustyKnight: I'm so annoyed I'm even thinking of developing a com server to do my UI work instead...but I think that is just a little over the edge

Why not just code your UI in Win32 or MFC? That'll save you from doing that, and lets you use all the UI stuff you want.
__________________


 
  12 December 2007
Thanks guys, I was so close, I kept trying to pass in the date values in an array as that is what is looked like it wanted. I should have looked closer as I do know that is how you pass values to function in other languages ie;(val,val,val) I should have guessed it was just the same as passing values to a function in Max. As for the parse method that might work for me as well. I'm slowely building up a list of dotNet controls in a Doc and will format them with small help tid bits at some point and post it all on my site. I have worked a great deal with XML, listview and treeviews at this point as well as several others.
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Originally Posted by scorpion007: Why not just code your UI in Win32 or MFC? That'll save you from doing that, and lets you use all the UI stuff you want.


How is this done?
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Yep, dotNetClass got me, it is dotNetObject, that is another reason that I wasn't even getting close.
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Well, simply put, Win32 is the fundamental C API for the windows platform.

.NET stuff (and MFC) is just a wrapper around it, in a higher level language.

If Max8 for example doesn't expose some .NET stuff that you need (RustyKnight mentioned a ListView), you can code it using the Win32 API. (MFC is fine apparently, but I don't have experience with it). BTW, MFC is basically a C++ wrapper around Win32 C API.

In other words, Win32 can do *everything*, MFC can do *most* stuff, and the stuff it can't you, you can fall-back to Win32. .NET can do whatever things that got implemented in it, provided Max lets you use them, but I don't have any experience with it either.

To answer "How to use Win32 API, and the ListView custom control", you'll need some preliminary knowledge with C, and some time to read a Win32 book. I'm not saying you 'should' do it, you may not need to -- if you already know .NET and you can use the ListView, and you're happy with it, great.

But if you can't for whatever reason, like what RustyKnight mentioned, you could definitely use Win32 code.

PS. I purposely didn't go into too much detail about the "How", because I don't want to overload you with low level details if you're not interested, or don't have the prerequisite knowledge. If you want more details, then let me know.
__________________


 
  12 December 2007
That is great, just what I was looking for. I don't know C but I have worked with C++. Just wonder where you were going with it. dotNet so far has worked well in Mxs and I'm able to do most of what I would like so far.
__________________
Paul Neale
http://paulneale.com
 
  12 December 2007
Originally Posted by scorpion007: Well, simply put, Win32 is the fundamental C API for the windows platform.

.NET stuff (and MFC) is just a wrapper around it, in a higher level language.

If Max8 for example doesn't expose some .NET stuff that you need (RustyKnight mentioned a ListView), you can code it using the Win32 API. (MFC is fine apparently, but I don't have experience with it). BTW, MFC is basically a C++ wrapper around Win32 C API.

In other words, Win32 can do *everything*, MFC can do *most* stuff, and the stuff it can't you, you can fall-back to Win32. .NET can do whatever things that got implemented in it, provided Max lets you use them, but I don't have any experience with it either.

To answer "How to use Win32 API, and the ListView custom control", you'll need some preliminary knowledge with C, and some time to read a Win32 book. I'm not saying you 'should' do it, you may not need to -- if you already know .NET and you can use the ListView, and you're happy with it, great.

But if you can't for whatever reason, like what RustyKnight mentioned, you could definitely use Win32 code.

PS. I purposely didn't go into too much detail about the "How", because I don't want to overload you with low level details if you're not interested, or don't have the prerequisite knowledge. If you want more details, then let me know.
I think the intention is to develope a cross platform API ... so you could walk from max 8 through max 9 (32 & 64) without tearing you hair out or kill any junior artiests...

Would you need to code it as a plugin or can you incorprate these controls directly into max script?

I've been working on an idea to use the com functionality of max to setup a server and pass and xml based document between max and my app...this would allow me to do alot of the ui outside of max (and get some OO going), while still getting access to the internals of max.

This is obviously for "large" scale apps, not simple ones...
__________________
If it's worth doing, it's worth scripting
Don't wish for this to be eaiser, wish for you to better
 
  01 January 2008
Okay, I'm not sure if the problem I am having is DotNet related or not, but it deals with the "Converting ActiveX ... to DotNet ..." tutorials files. Forgive me if the answer is obvious, I am still very new to this stuff. (Thanks Bobo, PEN, RustyKnight for getting me this far).

I am basically creating a split screen that shows a TreeView of objects and modifiers on one side, and a ListView of properties on the other. What I am stuck on is getting properties to update in the ListView from the scene. The code I have so far looks like this:

 
if (splitViewRollout != undefined) and (splitViewRollout.isDisplayed) do (destroyDialog splitViewRollout)
global splitViewRollout 
rollout splitViewRollout " Modifiers"
(
 -- TreeView
 fn initTreeView tv =
 (
  tv.checkboxes = true
  tv.sorted = true
 )
 fn addModifiers theNode theModifiers =
 (
  for m in theModifiers do
  (
   newNode = theNode.nodes.add m.name
   newNode.tag = dotNetMXSValue m
   newNode.checked = m.enabled
  )
 )
 fn addObjects theNode theObjects =
 (
  for c in theObjects do
  (
   newNode = theNode.nodes.add c.name
   newNode.tag = dotNetMXSValue c
   newNode.checked = not c.isHidden
   newNode.forecolor = (dotNetClass "System.Drawing.Color").fromARGB 200 0 0
   
   addModifiers newNode c.modifiers
  )
 )
 fn fillInTreeView tv =
 (
  theRoot = tv.nodes.add "(Objects)"
  rootNodes = for o in objects collect o
  addObjects theRoot rootNodes
 )
 -- ListView
 fn initListView lv =
 (
  lv.gridLines = true
  lv.view = (dotNetClass "System.Windows.Forms.View").Details
  lv.fullRowSelect = true
  
  layoutDef = #(#("Property", 120), #("Value", 60))
  
  for i in layoutDef do (lv.columns.add i[1] i[2])
 )
 fn fillInSpreadsheet lv =
 ( 
  lv.items.clear()
  theRange = #()
  
  if selection.count == 1 and myNode != undefined do
  (
   propNamesArray = getPropNames myNode
  
   for i = 1 to propNamesArray.count do
   (
	li = dotNetObject "System.Windows.Forms.ListViewItem" ((propNamesArray[i]) as string)
	sub_Li = li.subItems.add ((getProperty myNode propNamesArray[i]) as string)
	
	append theRange li 
   )
   lv.items.addRange theRange
  )
 )
 
 dotNetControl tv "TreeView" width:290 height:490 pos:[5,5]
 dotNetControl lv_Properties "System.Windows.Forms.Listview" width:290 height:490 pos:[305,5]
 
 on tv Click arg do
 (
  hitNode = tv.getNodeAt (dotNetObject "System.Drawing.Point" arg.x arg.y)
  
  if hitNode != undefined do
  (
   try
   (	
	if superClassOf hitNode.tag.value == modifier then (select hitNode.parent.tag.value)
	else (select hitNode.tag.value)
	
	global myNode = hitNode.tag.value
   )
   catch (max select none)
   
   fillInSpreadsheet lv_Properties
  )
 )
 on splitViewRollout open do
 (
  initTreeView tv
  fillInTreeView tv
  
  initListView lv_Properties
  fillInSpreadsheet lv_Properties
 )
)
createDialog splitViewRollout 600 525 style:#(#style_sysmenu, #style_titlebar, #style_toolwindow)
callbacks.addScript #preNodeGeneralPropChanged "splitViewRollout.fillInSpreadsheet splitViewRollout.lv_Properties"


Of course any general advice is appreciated, but I am trying to focus on one thing at a time until I get this working properly
 
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 05:33 AM.


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