|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| siContolStatic and AddStaticText different?
|
|
|
Hello,
I’ve got a siControlStatic field which I’m trying to dynamically change. The problem is that if the name of the field is not “Static” the label value doesn’t change.
You can use the following code to see what I mean (works in v7):
var oPSet = ActiveSceneRoot.AddProperty("CustomProperty", false, "staticHell");
var oLayout = oPSet.PPGLayout; oLayout.Language = "JScript"; oLayout.Logic = changeA_OnClicked.toString() +
changeB_OnClicked.toString();
var editorID = "a1"; oPSet.AddParameter3("oName"+editorID, siString, "A_" + editorID);
oLayout.addrow();
var oName = oLayout.AddItem("oName"+editorID, "", siControlStatic);
oName.SetAttribute(siUICX, 100);
var obttnA = oLayout.addbutton("changeA", "changeA"); oLayout.endRow();
oLayout.addrow();
var oName1 = oLayout.AddStaticText("blabla");
oName1.SetAttribute(siUICX, 100);
var obttnB = oLayout.addbutton("changeB", "changeB"); oLayout.endRow();
function changeA_OnClicked() {
PPG.PPGLayout.Item("oNamea1").label = "Refresh_ARGH"; //try commenting out
PPG.Refresh();
logmessage(PPG.PPGLayout.Item(0).name);
logmessage(PPG.PPGLayout.Item(0).label); }
function changeB_OnClicked() {
PPG.PPGLayout.Item("Static").label = "Goody " + Math.round(Math.random()*100);
PPG.Refresh();
logmessage(PPG.PPGLayout.Item(2).name);
logmessage(PPG.PPGLayout.Item(2).label); }
inspectobj(oPSet);
When changeA is clicked, the value does change (as output in the script editor), but it’s not updated in the PPG display.
When changeB is clicked, the value changes perfectly.
Do I need to do something else to make changeA work properly?
Thanks.
Edit: Another interesting thing is that if we comment out the line which says ‘//try commenting out’ the logged message doesn’t show the current label value, it’s just blank.
|
|
|
|
I Just checked, it’s nothing to do with AddStaticText. In the following code i’ve deleted the working AddStaticText box, and set the name of the siControlStatic box to ‘Static’. The code works fine. However, in my case, I need a few boxes with different names…
var oPSet = ActiveSceneRoot.AddProperty("CustomProperty", false, "staticHell");
var oLayout = oPSet.PPGLayout; oLayout.Language = "JScript"; oLayout.Logic = changeA_OnClicked.toString();
var editorID = "a1"; oPSet.AddParameter3("Static", siString, "");
oLayout.addrow();
var oName = oLayout.AddItem("Static", "bla", siControlStatic);
oName.SetAttribute(siUICX, 100);
var obttnA = oLayout.addbutton("changeA", "changeA"); oLayout.endRow();
function changeA_OnClicked() {
PPG.PPGLayout.Item("Static").label = "Goody " + Math.round(Math.random()*100);
PPG.Refresh();
logmessage(PPG.PPGLayout.Item(0).name);
logmessage(PPG.PPGLayout.Item(0).label); }
inspectobj(oPSet);
I still think it’s some sort of a refresh bug, since the values logged in the first post do reflect the correct values, they just aren’t updated on the ppg. I suppse the workaround would be to use a single line text box (which is not ideal)
|
|
|
|
I’ve got my script to work by using the “Static” name and to set values I’m using PPG.PPGLayout.Item(index).label where index is figured using some silly maths :)
|
|
|
|
|
|