Re: How to make a pause in a script ?

Date : Sat, 23 Jul 2005 16:00:23 +0200
To : XSI(at)Softimage.COM
From : guillaume laforge <guillaume.laforge.3d(at)gmail.com>
Subject : Re: How to make a pause in a script ?
Of course :-/
 
Thanks Brad !
 
 
 
2005/7/23, brad <brad(at)cg-soup.com>:
Hi Guillaume-

If you need your script to stop and wait for user interaction before proceeding, you can feed in an option to the InspectObj command making it modal, which means the PPG will float in a window above your XSI and wait until you either press okay or cancel. Check out the SDK docs on InspectObj first, but here's an example you can insert into your code:

// Inspect PPG and wait for user feedback
var isCanceled = InspectObj (oPSet, '', 'Select Path', siModal, false) ;

// If cancel button is clicked...
if(isCanceled){

   // you can exit out of your script here
   exit
}


-------Original Message-------
Hi,

I'm writing a script who save .ptp files somewhere. I would like to use a variable for
the .ptp path. I find "FolderPicker" in the doc who create a CPset with a path.

If the custom parameter already exist in the scene, there is no pb.
"oPSet.parameters("FolderPicker").Value"  give me the path the user choose before.

But if there is no custom parameter in the scene, it is create and then " oPSet.parameters("FolderPicker").Value" return nothing.
The user is not faster than the script and can't set the path before the logmessage :-p.

Here is the code :

var oPSet = ActiveSceneRoot.Properties (("ptp_path"));
if (!oPSet)
{
  //layout for selecting a folder where .ptp are saved.
  var oPSet=ActiveSceneRoot.AddProperty("CustomProperty",false,"ptp_path") ;
  oPSet.AddParameter3 ( "FolderPicker", siString ) ;
  var oPPGLayout = oPSet.PPGLayout ;
  var oItem = oPPGLayout.AddItem( "FolderPicker", "", "Folder" );
  oItem.SetAttribute( siUIInitialDir, "user" ) ;

  //Open the CustomPset to choose a path.
  //I can't "stop" the script during the user interaction...
  InspectObj( oPSet );

  //I would like to find the path now.
  logmessage(oPSet.parameters ("FolderPicker").value)
}
else
{
  //But I only find the path when the CustomPset already exist before the script.
  logmessage(oPSet.parameters("FolderPicker").Value)
}

Help !

Thanks,

Guillaume Laforge
CG artist / Jr TD
Antefilms studio


---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.