Notifications
Clear all

[Closed] Dotnet project

Okay as requested, I’ve cleaned up the code, removed unnecessary bits.


(
--Destroy dialog if it already exists.
try(destroyDialog quickStat)catch()

--Create a rollout
rollout quickStat "QuickStats v2.0" width:1100
(
	button killroll "Close" pos: [125,10] width:50 offset: [0,2]

		
		--Create the dotNet listview control
	dotNetControl lv "system.windows.forms.listView" pos: [12,40] height:450 width:1050
	
	


on killroll pressed do
(
	destroydialog quickStat
)


		
	
	--Innitialize the listview control
	fn initLv theLv=
	(
		--Setup the forms view
		theLv.view=(dotNetClass "system.windows.forms.view").details
		theLv.FullRowSelect=true		--Set so full width of listView is selected and not just first column.
		theLv.GridLines=true			--Show lines between the items. 
		theLv.MultiSelect=true			--Allow for multiple selections. 
		theLv.backColor=lv.backColor.FromArgb 100 154 154 -- Soften the background intensity a bit
)
	


	--Add columns. 
	   fn addColumns theLv columnsAr=
	(
		theLv.columns.add columnsAr[1] 80 	-- object name
		theLv.columns.add columnsAr[2] 110	-- material
		theLv.columns.add columnsAr[3] 80		-- Diffuse-map
		theLv.columns.add columnsAr[4] 80		-- Opacity-map
		theLv.columns.add columnsAr[5] 45		-- Polys
		theLv.columns.add columnsAr[6] 80		-- Pivot
		theLv.columns.add columnsAr[7] 110		-- material color
		theLv.columns.add columnsAr[8] 110		-- wire color
		theLv.columns.add columnsAr[9] 80		-- Lowest Point
		theLv.columns.add columnsAr[10] 80	-- Highest point
		theLv.columns.add columnsAr[11] 80	-- Poly or Mesh
	)
	
			 
	--Adds rows of data to the listView
	fn populateList theLv=
	(
		rows=#()		--Empty array to collect rows of data
		for x in objects do		--Loop through all the objects in the scene. 
		(
			li=dotNetObject "System.Windows.Forms.ListViewItem" x.name	-- column 1 :: 	--Create a listViewItem object and name it. 
			li.subitems.add((x.material) as string)										-- column 2 :: Add material data  use "o.material.name" to only show material names
			li.subitems.add ((texCheck) as string)										-- column 3 :: Adds difuse map texture name
			li.subitems.add ((matopamap) as string)										-- column 4 :: Adds opacity map texture name
			li.subitems.add (try((x.mesh.numfaces) as string)catch("--")) 	-- column 5 :: Add face count
			li.subitems.add ((x.pivot) as string)											-- column 6 :: Add face data 
			li.subitems.add  (try((x.material.diffuse) as string)catch("1 or more objects are VRAY materials or multisub materials"))	-- column 7 :: --model color rgb
			li.subitems.add ((x.wirecolor) as string)										-- column 8 :: Wirecolor rgb
			li.subitems.add  (x.min.z as string) 											-- column 9 :: Add the lowest position of object
			li.subitems.add  (x.max.z as string)											-- column 10 :: Add the lowest position of object
			li.subitems.add ((classOf x) as string)										-- column 11 :: Add class data 

			li.Tag = dotnetMXSValue x
			
			
			append rows li		--Added the listViewItem to the rows array
		)
		theLv.items.addRange rows		--Add the array of rows to the listView control. 
	)
	
	

			on refresh pressed do
(
			lv.items.clear()
			initLv lv
			populateList lv
				)
	
		
	on colstack pressed do
	(
		for o in selection do
			(
				converttopoly o
				clearSelection()
			)
	)
	

				
				
					on lv ItemSelectionChanged s a do
		(
			format "item:% selected:% node:%
" a.item.text a.isSelected a.item.tag.value 
		)
				

		on lv SelectedIndexChanged s a do
		(
			with undo off 
			(
				nodes = for k=0 to s.selectedItems.count-1 where isvalidnode (node = s.selectedItems.item[k].tag.value) collect node
				if nodes.count == 0 then clearselection() else select nodes
			)
		)
	

	on quickStat open do
	(
		initLv lv
		addColumns lv #("Objectname","Material","Diffuse-map","Opacity-map","Polys","Pivot","Material color","Wire color","Lowest Point","Highest Point", "Poly or Mesh")
		populateList lv
	)
	
		
)

--Create a dialog and assign the rollout to it. 
createDialog quickStat
)

I already solved one of my problems, column width.

So one of the other things I would like the list to do is: “if an object has a texture in the diffuse slot or opacity slot, to display the texture name next to the related object.”

I currently trying an if/else statement and see if I can a string output in the table but until now with no avail.

Using this piece I found on the net.

	   fn texCheck mat = if iskindof mat Material do
(
 if isproperty mat #diffusemap and isproperty (b = mat.diffusemap) #filename and \
  iskindof (f = b.filename) String  do b.name = getfilenamefile f

 )

:)… the texCheck function looks like mine. what’s wrong with it?

unfortunately i don’t understand UI design of your tool. that’s why it’s very hard for me to help you with a good advice.
you’ve posted a code of your tool, and i see you are not a sponger. but there are too much unnecessary “decoration” in you code.

please give us a clear idea what your tool should do and display.

Page 2 / 2