dotNet + MXS


#521

you are doing everything right. the problem is that you are using TreeView from your class to create dotnetcontrol. Max always uses object from first loaded assembly to create dotnetcontrol.you are recompiling and reloading the assembly, but max still using the first one

if you will use dotnetobject instead of dotnetcontrol, you will see the difference.



#522

Hi,
Sorry, I’m still unable to make it work :frowning:

try(destroyDialog theRollout)catch()
 (
 Testdll = "C:/Testdll.dll"
 local assembly = (dotNetClass "System.Reflection.Assembly").Load ((dotNetClass "System.IO.File").ReadAllBytes Testdll)
 local myClass = assembly.CreateInstance "TestNamespace.TreeView"
 
 rollout theRollout "Test" width:600 height:600
 	(
        local maxForm = dotNetObject "MaxCustomControls.MaxForm"
 	local myClass = dotNetObject "TestNamespace.TreeView"
 	on theRollout open do
  		(
		maxForm.controls.add myClass
                myClass.PopulateTreeView()
 		)
 	)
 createDialog theRollout
 )

I was hoping to create a 3dsMax rollout, embed a custom .NET TreeView and still keep the ability to re-compile the custom dll and NOT have to restart 3dsMax every time I re-build.

Am I missing something?

Mike


#523

it should be something like:


try(maxForm.close()) catch()
(
	Testdll = "C:/Testdll.dll"
	assembly = (dotNetClass "System.Reflection.Assembly").Load ((dotNetClass "System.IO.File").ReadAllBytes Testdll)

	global maxForm = dotNetObject "MaxCustomControls.MaxForm"
	myTreeView = assembly.CreateInstance "TestNamespace.TreeView"
   
	maxForm.controls.add myTreeView
	myTreeView.PopulateTreeView()
	maxForm.ShowModeless()
)


#524

Thanks Denis. I’m happy with getting it working in a .NET form and your code is perfect, BUT I was trying to get this functionality of dynamically re-loading the custom dll, so that the DotNetObject could be placed inside of a standard 3dsMax “rollout” UI. The issue seems to be that we rely on the “DotNetControl” wrapper to allow integration into the 3dsMax UI.

I was wondering if there is anyway around this issue, so I can have the best of both worlds…A dynamically re-loading dll which provides my custom Treeview AND the standard functionality of a 3dsMax “rollout” for UI design?

Is this possible? or am I committed to using MaxForm if I need to avoid using DotNetControl, so that I can “re-load” my assembly?

Hope this makes sense!

Thanks,
Mike


#525

in this case it has to be:


 try(destroydialog dialog) catch()
 rollout dialog "My TreeView" width:200 height:200
 (
 	Testdll = "C:/Testdll.dll"
 	assembly = (dotNetClass "System.Reflection.Assembly").Load ((dotNetClass "System.IO.File").ReadAllBytes Testdll)
 
 	dotnetcontrol panel "MaxCustomControls.MaxUserControl" width:190 height:190 pos:[5,5]
 	
 	on dialog open do
 	(
 		myTreeView = assembly.CreateInstance "TestNamespace.TreeView"
 		myTreeView.Dock = myTreeView.Dock.Fill
 		panel.controls.add myTreeView
 	)
 ) 
 createdialog dilaog
 

creating a dotnet object you can specify what assembly you want to use (just loaded in your case).
MAX loads dotnet control using first loaded assembly, and there is no way to change this behavior.


#526

did anyone has a luck to get “ManagedServices.MaxSpinner” works or shows?


#527

I’ve not had success with this either. Am I able to load in the DLLs with this method, and for examaple, say


  	 Testdll = ((pathConfig.GetDir #MaxData)+"Scripts\	urboTools\\FreeImageNET.dll")
  	dllMain = ((pathConfig.GetDir #MaxData)+"Scripts\	urboTools\	urboTools.BitmapUsage.dll")
  	 assembly = (dotNetClass "System.Reflection.Assembly").Load ((dotNetClass "System.IO.File").ReadAllBytes Testdll)
  	mainLoad = (dotNetClass "System.Reflection.Assembly").Load ((dotNetClass "System.IO.File").ReadAllBytes dllMain)
  	
  	   test  = mainLoad.CreateInstance  (dotnetobject "turboTools.BitmapUsage.form1")
	test.show()
	

#528

Hi Denis, I asked about this class on the Area SDK blog when they released the managed services dll. I was trying to find out how to develop classes using managedservices/dll without having to restart max each time (effectively bypassing the build error you get in VS)

but he did answer the question about maxspinner -

http://area.autodesk.com/blogs/chris/net_features_in_2010/comments


#529

i can’t say that has cleared the picture… thanks anyway. at least i know that i’m not the only one who puzzled.


#530

ha, yes. Answered enough to say to me “don’t pursue this any longer”


#531

Hi guys!
Does anybode figured out solution how to use dotnet for drawing in viewports?
I guess the way is create dialog that will flow viewport’s position and size.


#532

Hi,all.

Does anyboday meet dotnet cant read txt file with chinese character question ~?

Here is my maxscirpt:

  
 
 Txtfile="c:\\123.txt"  ---pls put 123.txt to your c:\ then can test this maxsciprt.
 if ((dotNetclass "System.IO.File").Exists Txtfile)
 then ( 
		  encodingClass = dotNetClass "System.Text.Encoding"
		  encoding = encodingClass.GetEncoding "GBK"
		  file =dotnetobject "System.IO.StreamReader" Txtfile encoding
		  runfile = file.ReadLine()
		  file.Close()
			)
  else(messagebox "need Txtfile";return())
  print runfile 
 

It’s empty when I print out the runfile, becuase some chinese character in the txtfile.
Ok, Let me upload the 123.txt , anybody can help me to test it.


#533

encodingClass.Default

Use Default property.


#534

Has anybody been able to figure out how to fix this?

Shame that the default UI for the devexpress tools is so ugly…


#535

it was not bad at the time of design. but it became very quickly… how to say… outmoded.
my point is that a tool has to be in the latest fashion… and it’s not a matter of discussion is the current fashion nice or ugly.


#536

Yeah the fact that I said it’s ugly is just my opinion, but the user should still be able to customise the appearance. At the very least the default appearance should be set to mimic the 3ds max UI for some consistency. I was trying to get the lookAndFeel property to work last night but was unable to do so. Not sure what else I can try to get this working.

I still think the default devExpress UI design is ugly :wink:


#537

well, stop playing up… :slight_smile:


#538

Hi everyone :smiley:

This can be usefull :wink:
http://www.dreamincode.net/forums/topic/67275-the-wonders-of-systemdrawinggraphics/


#539

Why error? - Runtime error: dotNet runtime exception: Non-static method requires a target. line - serializationJson.ReadObject memStream

Code:

clearlistener()
jsonData = “{“action”:“read”,“type”:“sequence”,“data”:[]}”

dotnet.loadAssembly “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll”

ascii_encoder = dotNetObject “System.Text.ASCIIEncoding”
encodedPostParams = ascii_encoder.GetBytes ( jsonData as string )
memStream = dotNetObject “System.IO.MemoryStream” encodedPostParams

serializationJson = dotNetClass “System.Runtime.Serialization.Json.DataContractJsonSerializer”
serializationJson.ReadObject memStream


#540

I think you have to create an object instance, like this:

serializationJson = dotNetObject “System.Runtime.Serialization.Json.DataContractJsonSerializer”

instead of trying to access its static method:

serializationJson = dotNetClass “System.Runtime.Serialization.Json.DataContractJsonSerializer”