Digital Art Zone

 
     
Browsing to file location using script
Posted: 04 September 2013 03:13 PM   [ Ignore ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13559
Joined  2003-10-09

Is it possible to perform the equivalent of the Content Library’s Browse to File Location, opening an OS file window, via script? I have found a browseToAsset(DzAssetPtr) function in the Content Library pane object, but I can’t see how to get an asset pointer from a file (ideally direct from a string with the relative path name, or the absolute path name obtained from DzContentMgr, though using a DzFile or FileInfo would be fine). As I am intending to use this, the Content Library would definitely not be showing the asset I wanted to browse to though I think it might be possible to switch to showing the asset in question - but the function also seems to need input other than a straight string or DzFile - and then go back to the original location.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 04 September 2013 09:48 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRank
Total Posts:  312
Joined  2003-10-09

The context is different (i.e. single file vs multiple files) and this simplifies dealing with database records, but here is a DAZ Script that roughly does what the “Browse to file location…” action in the Content Library context menu does:

var oPaneMgr MainWindow.getPaneMgr();
var 
oPane oPaneMgr.findPane("DzContentLibraryPane");
if( 
oPane ){
 
var aAssets oPane.getSelectedAssets();
 var 
sAbsFilePath;
 var 
oAssetoFileInfo;
 for( var 
0aAssets.length+= ){
  oAsset 
aAssets[i];
  
sAbsFilePath oAsset.getAsLocalFile();
  if( 
App.version64 >= 1125921381810178 ){//4.5.2.2
   
App.showInNativeBrowsersAbsFilePath );
  
else {
   oFileInfo 
= new DzFileInfosAbsFilePath );
   
App.showURLString("file:///%1").argoFileInfo.path() ) );
  
}
 }

-Rob

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 05 September 2013 05:51 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13559
Joined  2003-10-09

Ah, thank you - I thought there should be something in App but I wasn’t finding it. That’s much simpler than going through the content pane (I will be starting with the relative path available, so I just need to turn it absolute and use the show* function). Thanks Rob.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile