Notifications
Clear all

[Closed] The Viewport Maxscript Editor – NEW

In order to support nodes as .ms files, I’ve had to rethink how the script works.
So I wrote a high level description. It’s the new ‘architecture’ or whatever of the script as described in my own kind of psuedocode with the main events, script layout, and directory structure thought out. For me, this is a preparatory step before I begin writing out actual code.


   --	The Viewport Maxscript Editor V2
   --	by Garrick@GarrickCampsey 2011.03.01
   --	with DragAndDrop by Matthew Lichy
   
   --	High level description
   --	onScriptRun do
   --		load all category folders into categories dropDown
   --		load first node folders contents (.ms + .png files)
   --		build DragAndDropIcons from .pngs
   
   --	onDragandDrop icon dropped do
   --		load the proper .ms file
   --		get the build parameters from the .ms file;  build node based on these parameters (can be: rectangle or circle; and prox circle and text)
   --		get the code parameters from the .ms file;  write them to the node.CA.rollout.EditTextExe
   
   --	onWriteScript pressed do
   --		gather all nodes in scene, filter vme nodes with proper cas
   --		evaluate parent/child relationship to an ordered array
   --		for the array.count, add the node's CA.rollout.EditTextExe.text to source
   --		write source to file, fileIn file just written
   
   --	Script layout  --the script will write .ms files based on this layout
   --		global viewportMaxscriptEditor
   --		try destroyDialog viewportMaxscriptEditor catch()
   --		rollout viewportMaxscriptEditor " Viewport Maxscript Editor v1.1"
   --		(
   --			values
   --			fns declared
   --			--
   --			fns defined
   --			ui defined
   --			--
   --			events for ui
   --		) --close rollout
   --		createDialog viewportMaxscriptEditor
   
   --	Script directory layout
   --		vmeV2.ms
   --			/nodes/
   --				UIelements/ #(rollout, button, ,etc...)
   --				values/ #(value, integer, string, etc...)
   --				etc...
   

Usually people don’t like to share their ideas ‘in the raw’, but I think feedback should be included as soon as a point is reached where work can be reviewed. Also, I completely understand that I may of missed something or not thought something through completely… for example, I haven’t completely explored how to determine the parent/child array of nodes, but I think it’s possible. I’m also not completely sure how to store the build and write parameters in the .ms file while still keeping it a valid script. Little bugs to be thought out – I’ll just have to get creative

What does your code look like for that part?

Here’s my thoughts on how I’d like to write the .node files. These files would not be properly formatted .ms files, as I thought earlier. These files would contain the ‘build parameters’ and ‘write parameters’ for each node. I checked around and think that XML would be the best format to store this data. Here’s an example .node file:

<Node>
<BuildParams>string</BuildParams>
<WriteParams>string</WriteParams >
</Node>

I also wrote a function that adds double quote string literals to strings that aren’t formatted, since VMEv2 is going to be reading, converting, and saving code as strings on the fly. Fixing string literals takes up too much of my time scripting as well, so I hope to expand this function to be able to convert back and forth, for all string literals – including hex values. Here’s the beginnings of it:


  fn easyQuotes myString = (
  	local myFixedString = ""
  	for i = 1 to myString.count do
  	(
  		case of
  		(
  			(myString[i] as string == "\""): myFixedString += ("\\" + myString[i])
  			default: myFixedString += myString[i]
  		)
  	)
  	return myFixedString
  )
  myFixedString = (easyQuotes "myString")
  

@Matt: Here’s the code I’m using to get to the directory:


  local Thumbs = getFiles ("C:\Documents and Settings\Administrator\Desktop\vmeV2
odes\\*.png")

It may be a \ or / issue on my part. I’ll take a look later today.

jonahhawk: …Whatever the case, I can’t wait for all of the disparate node interfaces to be unified; schematic view, Node Joe/Slate, PFlow, the Orbaz toolboxes, Zoo Keeper. It all needs a unified UI.

@ jonahhawk: Really good point on this.

You have non-escaped newline character in the path as it is now. Just add @ before the string (2008+) or double backslash.

getFiles (“C:\Documents and Settings\Administrator\Desktop\vmeV2
odes\*.png”)

@Swordslayer: Good catch! Thanks! I was just learning about @ yesterday.

@ Kickflipkid687:

The address works now as: @“C:\Documents and Settings\Administrator\Desktop\vmeV2
odes*.png”

But, (and sorry to keep coming back with errors) now I’m getting:

Rollout:DragDropOps
 -- Error occurred in t loop; filename: C:\Documents and Settings\Administrator\Desktop\vmeV2\DotNetdragdrop.ms; position: 2574; line: 73
 --  Frame:
 --   btndragdrop: dotNetObject:System.Windows.Forms.Button
 --   t: "C:\Documents and Settings\Administrator\Desktop\vmeV2
odes
ode.png"
 --   img: dotNetObject:System.Drawing.Bitmap
 --   nothing: undefined
 --   bitInfo: #("C:\Documents and Settings\Administrator\Desktop\vmeV2
odes
ode.png", "PNG Image File", 100, 100, 8, 8, 1.0, 2.2, true, 0, 0, 6, 2)
 --   resizeBitmapNET: undefined
 --   buttonType: "node"
 --   called in DragDropOps.open(); filename: C:\Documents and Settings\Administrator\Desktop\vmeV2\DotNetdragdrop.ms; position: 2852; line: 82
 --  Frame:
 --   Thumbs: #("C:\Documents and Settings\Administrator\Desktop\vmeV2
odes
ode.png", "C:\Documents and Settings\Administrator\Desktop\vmeV2
odes\rollout.png")
 >> MAXScript Rollout Handler Exception: -- Type error: Call needs function or class, got: undefined <<

on the line:

img = resizeBitmapNET img bitInfo[3] bitInfo[4]

I tried to fix it, but my dotNet magic is weak.

Should be this function, I guess: http://forums.cgsociety.org/showpost.php?p=6039270&postcount=13

Edit: you can actually just comment out the line, it doesn’t change anything

If your images are already the right size (there’s no reason they shouldn’t), you can avoid the intermediate local img declaration and .Image = img assignment and just add local imageFromFile = (dotNetClass “System.Drawing.Image”).FromFile to the list of locals at top of the rollout definition and call .Image = imageFromFile t during the loop instead.

@Swordslayer: That gets it working! Drag and drop is now functional.

A couple of updates:

  1. the UI will be customized, based on rtt assist and example code by codefather (much respect!)
  2. the xml data will use a CDATA tag to store code strings (XML read/write based on PENs tutes)
  3. the easyQuotes fn now converts predefined entities for strings, maxscript, and xml
  4. every node will have an editTextBox popup written into their custom attributes tied to the XML

There is lots to do. I’ll try not to litter the forum for a few weeks!
Here is early UI tests:

I’m very happy to release VME version 1.2. Here’s what’s new:

 1.  You don't have to link UI elements to Rollouts any longer.
 2.  This version 'cleans' scene node's names, so invalid code isn't generated.
 3.  This version has a UI built to match Max 2011's UI style.
 4.  This version has both Light and Dark skins, just like Max.
 5.  Drag and drop nodes from the script's bin into the viewport to create them.
 6.  You can also hold shift+click to create a node instantly.
 
 Here's some visuals:
 
 [img] http://www.garrickcampsey.com/media/VMEv1p2Themes.jpg [/img]
 
 [img] http://www.garrickcampsey.com/media/VMEv1p2newUI.jpg [/img]
 
 And (as always) a stress test:
 
 [img] http://www.garrickcampsey.com/media/VMEv1p2stressTest2.jpg [/img]
 
 Here's a code snippet showing how VME strips out certain characters from names:
 
 [img] http://www.garrickcampsey.com/media/VMEv1p2cleansNames.jpg [/img]
 
 
 [b]Here's what's planned next for VME[/b] :
 1.  Get ImgTag nodes working, with custom attributes that determine the bitmaps for the 'normal' and 'over' states of the ImgTag.  This code should be written automatically as well.
 2.  Write events for UI elements by default.  Add 'offset:' functionality into write code.
3. Get the 'dynamic reskinning' working in a stable way.  Sometimes it works, sometimes it doesn't.  It [i]always[/i] works if you edit the ms file to point to the right directory.  Weird...

You can download the new version from the first post of this thread.
The UI skin folder needs to exist in the same directory as the VME.ms file.

Just unzip the archive to a folder and run the .ms file. There is no install.

I've also relinked all prior releases, so you can download those if you'd like to.

Here are some concepts for the next version’s UI:

A more ‘modern’ dark and lite combo

sam flynn’s vme… also clu’s vme

matrix-y vme:

Really slick By the way you might want to consider allowing users to drop the controls somewhere else than to the predefined position. It’s not so hard to add a test at what position it has been dropped to provide the property for your myUIelement :). Something like this,

try destroyDialog VME_test catch()
rollout VME_test "Drag and Drop Test" height:180 width:240
(
	local btnArr

	dotNetControl dncPanel "FlowLayoutPanel" pos:[0,0] width:VME_test.width height:VME_test.height

	fn onMouseMove sender args =
	(
		if (sender.ClientRectangle.Contains args.x args.y) then
			setSysCur #arrow
		else setSysCur #move
	)

	fn onMouseUp sender args =
	(
		if NOT (contains (Box2 (getDialogPos VME_test).x (getDialogPos VME_test).y VME_test.width VME_test.height) mouse.screenPos) AND mouse.pos.x > 0 AND mouse.pos.y > 0 then
		(
			local clrIndex = findItem btnArr sender - 1
			local dropPos = gw.getPointOnCP mouse.pos
			box wirecolor:(color clrIndex clrIndex clrIndex) pos:[dropPos.x,0,dropPos.y] --for front view
		)
		else messageBox "This is not a good place to drop it!"
	)

	fn exitDialog =
	(
		dncPanel.Controls.Clear()
		(dotNetClass "System.GC").Collect (dotNetClass "System.GC").MaxGeneration (dotNetClass "System.GCCollectionMode").Forced
		destroyDialog VME_test
	)

	on VME_test open do
	(
		local clrClassFromARGB = (dotNetClass "System.Drawing.Color").FromARGB		
		local btnDragDrop, btnClass = dotNetClass "System.Windows.Forms.Button", btnSize = dotNetObject "System.Drawing.Size" 15 10, btnMargin = dotNetObject "System.Windows.Forms.Padding" 0 

		local btnClose = dotNetObject btnClass
			btnClose.Size = dotNetObject "System.Drawing.Size" 240 20
			btnClose.Margin = btnMargin
			btnClose.Text = "Exit"
			
		dotNet.addEventHandler btnClose "Click" exitDialog
			
		dncPanel.Controls.Add btnClose

		btnArr = for btn = 0 to 255 collect
		(
			btnDragDrop = dotNetObject btnClass
				btnDragDrop.Size = btnSize
				btnDragDrop.Margin = btnMargin
				btnDragDrop.BackColor = clrClassFromARGB btn btn btn
				btnDragDrop.FlatStyle = btndragdrop.FlatStyle.Flat
				btnDragDrop.FlatAppearance.BorderSize = 0

			dotNet.addEventHandler btnDragDrop "MouseMove" onMouseMove
			dotNet.addEventHandler btnDragDrop "MouseUp" onMouseUp
				
			btnDragDrop
		)

		dncPanel.Controls.AddRange btnArr
	)
)
createDialog VME_test style:#()

Page 6 / 9