DotNet and messagebox problems

DotNet and messagebox problems

Anonymous
Not applicable
523 Views
4 Replies
Message 1 of 5

DotNet and messagebox problems

Anonymous
Not applicable
Hi,

I have recently updated one of my scripts to include some dotNet elements in its rollouts (bold
and colorful fonts).

The script has two pickbuttons that let you choose objects in the scene. If the picked objects do not have the right modifiers for the script to work, or the right controller - it pops up a messagebox saying that the object is invalid.

That worked just fine before dotNet. Now that dotNet is introduced - I get the messageboxes fine - but I lose the ability to interact again with my dialog rollout. All the GUI functions on it are dead. If I disable the messagebox - all works fine.

What is it about dotNet and messageboxes that prevents the re-use of the script - so that the user can pick the correct object if the previous one turned up to be wrong?

Thanks.
0 Likes
524 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
OK - it's much easier to explain with an example.
Please copy and use the code below. A simple interface with radiobuttons and pickbuttons. The radiobuttons work, as well as the pickbutton. Once you select an object with the pick button (which will not be called "test01"), the script will pop up a messagebox claiming it's the wrong object. From there you can't go back to the script to choose again, and the radiobuttons won't work.

BTW - I've found that I need to disable the groupbox - otherwise I get the same behavior of not being able to interact with the interface.


rollout dotNetProblem "dotNet Problem" width:278 height:170
(
dotNetControl grpType "groupBox" pos: enabled:false
radiobuttons objectType labels:#("Mesh", "Spline") default:1 columns:2
label lObj "Picked: Mesh"
dotNetControl lblTitle "label"
pickButton bPick "Pick Object" pos: width:100 height:20
button bGo "Go" pos: width:120 height:30 enabled:false

on dotNetProblem open do
(
lblTitle.text = "dotNet Title"
grpType.text = "dotNet groupbox title:\t"
grpType.width = 268
grpType.height = 150
bgcolor = (colorman.getcolor #background)*255
dnbgcolor = (DotNetClass "System.Drawing.Color").FromArgb bgcolor bgcolor bgcolor
lblTitle.BackColor = dnbgcolor
grpType.BackColor = dnbgcolor
dnFontStyle = dotNetClass "System.Drawing.FontStyle"
myFontStyle = dotnet.combineenums dnFontStyle.bold --dnFontStyle.italic
boldDNfont = dotNetObject "System.Drawing.Font" "MS Sans Serif" 8 myFontStyle
lblTitle.Font = boldDNfont
grpType.Font = boldDNfont
grpType.ForeColor = (DotNetClass "System.Drawing.Color").FromArgb 0 0 100
)

on objectType changed state do
(
if (objectType.state ==1) then lObj.text = "Picked: Mesh"
if (objectType.state ==2) then lObj.text = "Picked: Spline"
)

on bPick picked obj do
(
if obj != undefined then
(
if obj.name != "test01" then
(
messagebox "Object is not \"test01\"" -- <- Try commenting this out to make it work
obj = undefined
return 0
&#41; else &#40;
bGo.enabled = true
bPick.text=obj.name
&#41;
&#41;
else &#40;return 0&#41;
&#41;

on bGo pressed do
&#40;
messagebox "You chose \"test01\" - now try again"
&#41;

&#41;
createdialog dotNetProblem


Thanks!
0 Likes
Message 3 of 5

Anonymous
Not applicable
First add which Max version you use in your sig to can people help you without ask.
Don't worry, and I did not know this at the beginning :&#41;
I have no experience with dotNet but test your code in my 3dsmax 2009 x64 and the messagebox works, but after picking "wrong" object &#40;ie not "test01"&#41; - whole rollout controllers go out &#40;freezed&#41; and not accessible. In second pass test I just remove dotNet groupBox control and now works fine :&#41; I hope this helps a little bit.
rollout dotNetProblem "dotNet Problem" width:278 height:170
&#40;
radiobuttons objectType labels:#&#40;"Mesh", "Spline"&#41; default:1 columns:2
label lObj "Picked: Mesh"
dotNetControl lblTitle "label"
pickButton bPick "Pick Object" pos: width:100 height:20
button bGo "Go" pos: width:120 height:30 enabled:false

on dotNetProblem open do
&#40;
lblTitle.text = "dotNet Title"
bgcolor = &#40;colorman.getcolor #background&#41;*255
dnbgcolor = &#40;DotNetClass "System.Drawing.Color"&#41;.FromArgb bgcolor bgcolor bgcolor
lblTitle.BackColor = dnbgcolor
dnFontStyle = dotNetClass "System.Drawing.FontStyle"
myFontStyle = dotnet.combineenums dnFontStyle.bold --dnFontStyle.italic
boldDNfont = dotNetObject "System.Drawing.Font" "MS Sans Serif" 8 myFontStyle
lblTitle.Font = boldDNfont
&#41;

on objectType changed state do
&#40;
case state of &#40;
1: lObj.text = "Picked: Mesh"
2: lObj.text = "Picked: Spline"
&#41;
&#41;

on bPick picked obj do
&#40;
if obj != undefined do
&#40;
if obj.name != "test01" then
&#40;
messagebox "Object is not \"test01\""
bGo.enabled = false
bPick.text = "Pick Object"
&#41; else &#40;
bGo.enabled = true
bPick.text = obj.name
&#41;
&#41;
&#41;

on bGo pressed do
&#40;
messagebox "You chose \"test01\" - now try again"
&#41;
&#41;
createdialog dotNetProblem
0 Likes
Message 4 of 5

Anonymous
Not applicable
Sorry about that - I'm using Max 2008. I also am running Max 2010 - but only seldom use it because most of our clients have not upgraded yet - so - putting 2010 in my signature wouldn't have helped. I still should have mentioned that.

As for the groupbox - yes - it seems that that's where part of the problem is - but the workaround doesn't explain the problem. What if I do want to use a groupbox with a dotNet formatting?

I noticed that if the script starts with the groupbox enabled - I get the "freeze" behavior as well. However, if I try to re-disable it once a wrong object is picked - it doesn't seem to matter - I still cannot access the buttons.

Thanks.
0 Likes
Message 5 of 5

Anonymous
Not applicable
My short playing around with dotNet draw a conclusion so
Max UI controllers and dotNet controllers are not compatible at all.
I've still not met anyone who can explain these problems.

I see only 2 solutions at the moment -
1. Don't use dotNet where you can done without it assistance.
2. If you use dotNet then done all job without Max rollouts controllers,
ie use dotNet objects and controllers only, even dialog form if necessary.

However, there is no guarantee that I'm right 😄
0 Likes