Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / Problems using the _onChanged() event
  RSS 2.0 ATOM  

Problems using the _onChanged() event
Rate this thread
 
30114
 
Permlink of this thread  
avatar
  • Total Posts: 16
  • Joined: 20 February 2008 10:45 AM

Hi, I have got a problem using the _onChanged() event of PPGs.

When using this code, it is not possible to set values from the _onChanged() method to my PPG if I use the following line:

oPSet.Parameters("oSizeimageWidth").value oPSet.oSizeimageWidth.value oPSet.oSizeFactorX.value;

If I use

oPSet.Parameters("oSizeimageWidth").value 666

everything is fine. Now the strange thing is, that I can log the right part of the equation, which spits out the
correct value:

LogMessage("my oversized imageWidth is: " oPSet.oSizeimageWidth.value oPSet.oSizeFactorX.value);

Does anyone have a clue?
Thanks.

Here is the whole code (select a camera and run the script):

// SELECT A CAMERA AND RUN THE SCRIPT

// GET CAMERA
    
var oSel Application.Selection;
    if (
oSel(0).type == "camera")
        
{
        doLayout
();
        
}
    
else
        
{
        Application
.LogMessage("No camera selected!");
        
}


// PPG LAYOUT
function doLayout()
{

    
var $origImageWidth GetValue("Passes.RenderOptions.ImageWidth");
    var 
$selectedCamName oSel(0).Name;
    var 
$selectedCam oSel(0).FullName;

    var 
oCProp ActiveSceneRoot.AddProperty("CustomProperty",false"oversizer");
    
    
oCProp.AddParameter3('oSelectedCam',siString,$selectedCam);
    
oCProp.AddParameter3('oSizeFactorX',siFloat,1,1,6.66,true);
    
oCProp.AddParameter3('oSizeimageWidth',siFloat,$origImageWidth,1,1000,false);
    
    var 
oLayout oCProp.PPGLayout;
    
oLayout.AddItem('oSizeFactorX');
    
oLayout.AddGroup('Oversized values: ' $selectedCam);
        
oLayout.AddSpacer(0,5);
        
oLayout.AddRow();
            
oLayout.AddItem('oSizeimageWidth','oSize Width',siControlString);
    
oLayout.EndRow();
    
oLayout.EndGroup();
    
    
oLayout.Language 'JScript';
    
oLayout.Logic oSizeFactorX_OnChanged.toString();
    
    
InspectObj(oCProp,null,null);
    
}
    
function oSizeFactorX_OnChanged()
{    
        
var oPSet PPG.Inspected(0);
        
//this does work:
        
LogMessage("my oversized imageWidth is: " oPSet.oSizeimageWidth.value oPSet.oSizeFactorX.value);
        
        
//but when applying to the oPSet, this doesnt work:
        
oPSet.Parameters("oSizeimageWidth").value oPSet.oSizeimageWidth.value oPSet.oSizeFactorX.value;
        
        
//applying it to a fixed value works though...:
        //oPSet.Parameters("oSizeimageWidth").value = 666;
}


Replies: 0
avatar

I think you are getting the error because your oSizeFactorX_onChanged event is changing the oSizeFactorX value - which is causing a cycle.

You can either use another slider to display the final value - or try the onValueChange event

Chin



Replies: 0
avatar

Hi Chinny,

thanks for your reply. I got it working now.
The mistake was that I intialised the parameter with a maximum value of 1000
and the script alters the value to a higher number than that.

oCProp.AddParameter3('oSizeimageWidth',siFloat,$origImageWidth,1,1000,false);

changed to

oCProp.AddParameter3('oSizeimageWidth',siFloat,$origImageWidth,1,9999,false);

and that worked.

Thanks



Replies: 0