[Closed] Dotnet project
I’m working on a big script, called “quick stat”. Which is a panel that displays various kinds of information on the items in the scene.
f.e.: name of the object, material, diffuse map name and lots and lots of other data.
I’m nearly done but there are still a couple of things that I just don’t seem to get working
-
I want to display (diffuse and opacity maps) IF used next to the object name
-
I would like the set the width of all columns manually.
-
I would like to insert a compare script that if the (f.e. material color and wire color are different) the numbers will be show in red.
-
IF possible I want to add a sort function, that if you click on each column it will sort automatically.
Any ideas, suggestions that can get me into the right direction?
I’m posting the whole code here, please bare with me, the code is very dirty.
(
--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
)
anyone?
You don’t have to fix the script if only help me into the right direction I would appreciate it very much.
how to say?.. this project looks very personal… and big for a shallow comment.
it might be better to break it on UI, technical, and logical parts… just make it easier for comment.
Hmmmm weird I have laid out the questions quite clearly no?
Perhaps 1 question at a time?
Im trying to read all the textures being used in the scene and trying to display them next to respective objects in the list.
If you run the script, there is a button that selects only objects that are textured, I want to use that part of the code to write a function and then read it into the list but so far I have failed.
I also found this piece of code before, but cant get it to work.
( out_name = "c:\ est.txt" out_file = createfile out_name for o in geometry do ( if (hasproperty o.material "diffuseMap")then ( if (o.material.diffuseMap != undefined)then ( if (hasProperty o.material.diffusemap "filename")then ( matdifmap = o.material.diffuseMap.filename if (matdifmap != undefined)then ( format "dif-texture-name: %
" matdifmap to:out_file ) ) ) ) if (hasproperty o.material "opacitymap")then ( if (o.material.opacityMap != undefined)then ( if (hasProperty o.material.opacityMap "filename")then ( matopamap = o.material.opacityMap.filename if (matopamap != undefined)then ( format ",
opa-texture-name: %
" matopamap to:out_file ) ) ) ) ) close out_file )
Mind you this was part of a code to get all texture names saved to a .txt file.
i’ve read your code more carefully. unfortunately i can’t run it because the code was written for very specific case and can’t work in general.
honestly everything is wrong. i don’t a see a line that looks pretty much correct. that’s why i suggested you to break your question(s) on parts, and do what you are doing step-by-step with better understanding what you do.
i would start from – “how to find nodes that have a material with a specific texture…”
i don’t want say anything without adducing a proof… check the first function in your code that does do something:
fn FaceArray=
(
for o in geometry do
( max modify mode
modPanel.addModToSelection (Poly_Select ())
converttopoly o
subobjectLevel = 4
count = polyop.getNumFaces o -- Hoeveel faces zijn er
idArray = #(0) -- Array met faceId's die je wilt selecteren, nu bv 0 en 1 / bv idArray = #(0,1,2)
selectFaces = #{} -- Maak een bitarray voor de te selecteren faces
selectFaces.count = count -- Init de bitarray met een standaard lengte (sneller)
for i = 1 to count where findItem idArray (polyOp.getFaceSmoothGroup o i) != 0 do selectFaces[i] = true -- loop over alle faces en als de id matched zet de bitArray bit op true
polyOp.setFaceSelection o selectFaces -- en zet de selectie maar
smthgrps = polyOp.getFaceSelection o
collapseStack o
)
)
this is not your function… you copied and pasted from another ‘author’. at least i don’t have any idea why you made comments on hmm… Dutch(?)
whole function doesn’t make any sense.
max modify mode
modPanel.addModToSelection (Poly_Select ())
converttopoly o
...
collapseStack o
two first lines are just silly after the third… and last line makes everything absurd…
ohhh… next code is worse. just tell me please what this function expects to do…
let me guess… it has to collect (and select) all poly faces of a poly node which have any smoothing group applied. true?
because you convert every node of geometry to poly in your loop i can guess you are looking for editable poly nodes…
for node in geometry where iskindof node editable_poly do
(
faces =#{}
for f=1 to node.numfaces where (polyop.getfacesmoothgroup node f) != 0 do append faces f
node.selectedfaces = faces
)
that’s it.
I had to recheck where this part is from, but this part is to check whether object has NGON’s or not. But actually I will do that with a separate script. So this FN can actually be removed, you can see its not in the column section either.
As I said, this code is very dirty. Ive done a lot of copy and pasting, deleting, editing etc.
BTW are you assuming I stole the code? It’s code I’ve collected from the net over the years while making scripts. And yes that is Dutch. Don’t ask me why its in Dutch, I use both Dutch and English and don’t see what it has to do with any of this.
As for your questions:
max modify mode modPanel.addModToSelection (Poly_Select ()) converttopoly o ... collapseStack o
In max when you want to add an editpoly modifier it sometimes didn’t work, because you needed to give max a command to switch to the modifier panel first, that’s why that is there.
The collapse stack was added because some objects in big scenes didn’t automatically collapse the stack so I had to force it.
converttopoly == collapsestack for sure… collapse doesn’t make sense after you converted a node to poly
i don’t say you steals anyone’s code. i use a code from free resources all the time. i say you’ve just picked the wrong one.
the post is named “dotnet project”… i’m ready to help, but give us at least something to play with please
i see that the snippet you posted is about nothing. it doesn’t work. it contains unused functions.
that’s why i asked you to make your question a little bit more objective.