Browsing to file location using script

Richard HaseltineRichard Haseltine Posts: 20,450

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.


  • rbtwhizrbtwhiz Posts: 524
    edited September 2013

    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 oAsset, oFileInfo; for( var i = 0; i < aAssets.length; i += 1 ){  oAsset = aAssets;  sAbsFilePath = oAsset.getAsLocalFile();  if( App.version64 >= 1125921381810178 ){//   App.showInNativeBrowser( sAbsFilePath );  } else {   oFileInfo = new DzFileInfo( sAbsFilePath );   App.showURL( String("file:///%1").arg( oFileInfo.path() ) );  } }}


    Post edited by rbtwhiz on
  • Richard HaseltineRichard Haseltine Posts: 20,450
    edited December 1969

    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.

Sign In or Register to comment.
Rocket Fuel