Monthly Archives

April 2015

DataGridView Sorting Sorted!

By | Blog, Maxscript | No Comments

I encountered this issue whilst developing my plugin Mission Control; if the dotNet dataGridView has been sorted using the column headers, it seems that the indexes returned by (dgv.selectedRows()).item[#].rowindex or the tags returned by (dgv.selectedRows()).item[#].tag.value all point to the non-sorted rows of the dgv.

This would be a big problem for my plugin as being able to sort the spreadsheet is a key functionality of the tool and the only alternative method I could think of was to put all my data through a dataTable… not something I was keen to implement at this stage of the development.

Thankfully, after a little experimentation I realised that dgv.selectedRows() wasn’t the only way to obtain the current selection of a sorted dgv; I could have used dgv.selectedCells() and then collected the unique rowindex’s or row pointers from my tags. Although this is slightly heavier in terms of processing more data (especially with large selections of many columns), a solution that works slowly is better than no solution at all!

Problem solved!

…thanks due to DenisT (cgtalk forums) for the encouragement!

The camel that got the hump, or how I learnt to respect existing Names

By | Blog, Hints and Tips, Maxscript | No Comments

Whilst developing Mission Control for 3ds Max, I came across an unusual bug where a name I was using “#vrayproperties” was becoming camel-cased to “#vrayProperties” and causing my script to fail. I had previously called the name #vrayProperties, so I thought I hadn’t managed to change all the instances to non-camelCased, but after doing a string search and replace, there were definitely no cases of the camelCased version in my script.

I though that maybe the value was being retained in a global variable, but even restarting max didn’t fix the problem. Then I thought it might be a weird dotnet persistance issue, so I restarted windows… but still no joy! Then it clicked, perhaps the name is being defined somewhere else before my script is being executed? So, to test this I replaced #vrayProperties with #vrproperties, and lo and behold the problem was solved.

Lesson learnt, be careful with name naming!

Skip to toolbar