Digital Art Zone

 
     
What is the DS4.5 script to change content library pane to particular diectory?
Posted: 09 October 2012 03:45 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15674
Joined  2003-10-09

Try
findPane( “DzContentLibraryPane” )
that’s what works in my FixDuplicateIDs script - the name changed, I think, to reflect that there are now several panes that can be Libraries - Content Library, Smart Content and the perhaps Preset tabs of the parameter and setting panes.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 09 October 2012 04:54 PM   [ Ignore ]   [ # 4 ]
Active Member
RankRank
Total Posts:  390
Joined  2004-03-03

Executing Script…
Script Error: Line 3
TypeError: Result of expression ‘MainWindow.getPaneMgr().findPane( “DzContentLibraryPane” ).setCurrentFolder’ [undefined] is not a function.
Stack Trace:
<anonymous>()@:3
Error executing script on line: 3
Script executed in 0 secs 31 msecs.

Well, still doesn’t work, but appears to get further. Has setCurrentFolder changed in some fashion?

Profile
 
 
Posted: 10 October 2012 08:19 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15674
Joined  2003-10-09

Folder has been replaced with Container, since the pane might be showing a category rather than a folder on disc. Rob’s trick for seeing the methods available for an object is

var paneMgr MainWindow.getPaneMgr();
var 
pane  paneMgr.findPane"DzContentLibraryPane" );
for ( var 
i in pane {
 
print( i);

and using that I can see a way to get the current container, but not to set the current container. Sorry.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 15 October 2012 11:25 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRank
Total Posts:  373
Joined  2003-10-09

Here is an example that I’ve just posted to the Scripting Samples section on the Documentation Center. It shows how its done for each of the top-level containers.

-Rob

 Signature 

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

Profile
 
 
Posted: 16 October 2012 07:40 AM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15674
Joined  2003-10-09

Thanks Rob.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 16 October 2012 08:34 AM   [ Ignore ]   [ # 8 ]
Active Member
RankRank
Total Posts:  390
Joined  2004-03-03

Thanks very much, Rob .... I hope, if I can figure this out.

This is important enough to me that it will hopefully let me continue using DS, as purely the inability to have shortcut scripts to locations in the Poser and DS formats parts of the DS content library has been driving me to look at moving to Poser. Quite apart from all the stuff that means I can’t do anything at all with the computer most of the time, I’ve now developed a thing where, even when I am able to use the computer, for a while now I’ve had stabbing pains under my wrist every scroll or click. As I don’t want to just render portraits of a single figure with just a hair and a material setting, but rather scenes with lots of characters, props etc, having to navigate up and down, up and down, up and down between the Poser and DS format content has become just too painful. Having a menu of actions to shortcut jumps to particular places, and scripts in certain folders to jump to certain other folders should get using the content library usable again for me.

As a complete non scripter, though, this is a lot more complicated than the one-line script I used to use in DS3 quoted in the first post, where it was obvious what to change for shortcuts to different places (i.e. just the absolute path to the folder wanted).

Trying to work through this, I’m guessing ....

// Set the id used by the switches
var sContainer = sStudioDir;

leave that for a shortcut to a DS content folder, change sStudioDir to sPoserDir for a Poser format folder.

And for DS fomat content ...

sBase = oContentMgr.getContentDirectoryPath( 0 );

change the number in the brackets for content in different DS format content folders (I have My Library, my DS3 content and my DS2 content) - presumably they number top down as they appear in the content library display, starting at 0 at the top. Then edit the relative path in sRelative = “Scripts/Utilities”; for the actual folder.

While for a Poser format folder in a pathed runtime ....

sBase = String(”%1/Runtime/Libraries”).arg( oContentMgr.getPoserDirectoryPath( 0 ) );

again change the number for the different runtimes (I have 7), numbered down as they are listed in the content library. Then edit the relative path starting from below runtime:libraries in sRelative = “Character/DAZ People”;

Is that right?

And just to keep the script sizes down, I suppose one could omit all the ‘case’s other than the sStudioDir ones in shortcuts to studio format folders, and all but the sPoserDir ones in shortcuts to Poser format folders.

Assuming that’s correct-ish, i should be able to sort out a menu of shortcut scripts, and shortcut links between folders. So that will be great. Thanks again.

As a suggestion for a Product or freebie from someone, though, a script that would create the shortcut script to the selected folder would be very good. Two tools (or one tool that carried out both functions): one to create shortcut scripts for a favorites menu (or tab); one to create shortcut scripts from one folder to another.

Profile
 
 
Posted: 16 October 2012 10:07 AM   [ Ignore ]   [ # 9 ]
Active Member
RankRank
Total Posts:  390
Joined  2004-03-03
DavidGB - 16 October 2012 08:34 AM

Assuming that’s correct-ish, i should be able to sort out a menu of shortcut scripts, and shortcut links between folders. So that will be great. Thanks again.

Just in case someone else like me - doesn’t actually know how to write these scriipts, but is happy to load them into a text editor and customize them according to simple instructions - ends up reading this, looking to produce shortcut scripts to naviagte round the DS and Poseer format content library folders: what I put above was correct. I now have a working template script to customize as above to jump to DS format folders in the content library pane, and another template script to customize to jump to Poser format folders.

grin

Thanks again, Rob.

The one thing I still need to try and get my head round ....

After updates to DAZ Studio, I generally find I need to go to Windows>Workspace>Customize and import the new default Menus, Actions and Toolbars (not layouts, as I want to keep my standard layout) to make sure I get the changes that have come with the update: new menu entries, things changing names or moving from one menu to another, new tools in the toolbars etc. But that then loses me e.g. a custom Favorites menu from the menu bar, and customized toolbars that present the tools i use rather than those I don’t or hardly ever use. And it’s a bit of a pain having to recreate then.

I’m sure there must be some way of keeping a custom toolbar and a custom menu so that, after an update and calling up the new defaults, I can e.g. restore a Favorites menu to the menu bar with a click rather than rebuilding it (or simply just keeping it while still getting any changes to the normal menus), or keeping (differently named) custom Input Ouput, Creator Tools etc toolbars to use instead of the default ones, so after seeing the new defaults and whether there are some new entries I should put on my custom ones i can switch back to the custom ones. But I’ve never quite figured out how. But being sure to get the new stuff and changes has always ment losing my custom menus and toolbars and having to rebuild them from scratch. Well, apart from hand hacking the action. toolbar and menu .dsx files, copying in stuff from old saved versions into the new defaults, which is more of a pain that rebuilding things in the Customize pane. I’m sure I’m missing something.

Profile
 
 
Posted: 16 October 2012 12:34 PM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRank
Total Posts:  373
Joined  2003-10-09

You’re welcome.

The example is intended to show how each of the top-level containers work within the same script so that you can see the differences/similarities between them. A script that changes the active container for a specific top-level type would be a fraction of that example - the majority of the length is in the comments, newlines for readability and switch statements, which would mostly vanish in a specific script.

For instance, a much leaner version of the example script where you change to a DAZ Studio formats sub-container… without all the extra stuff used to teach:

// DAZ Studio version 4.5 filetype DAZ Script
var oPane MainWindow.getPaneMgr().findPane"DzContentLibraryPane" );
if( 
oPane ){
 
var sBase App.getContentMgr().getContentDirectoryPath);
 var 
aIdPath [ App.getAssetMgr().getStudioDirID(), sBase ];
 var 
aRelativeParts "Scripts""Utilities" ];
 for( var 
0aRelativeParts.length+= ){
  aIdPath
.pushString("%1/%2").argsBase ).argaRelativeParts.slice(01).join("/") ) );
 
}
 oPane
.browseToIDPathaIdPath );
 
oPane.updateContaineraIdPath );

The script is more complicated because the Content Library pane does a whole lot more than the old Content pane did. Easier for the user typically means harder for the developer. That is simply the nature of the beast.

BTW, your single-line script has no error checking/reporting to speak of - there are multiple points of potential failure. If something went wrong in a script you would probably be lucky enough to only cause an error… in C++ you could cause a crash. A more complete version of the script above that is closer to production ready, would look something like this…

function setContentLibraryNativeFormatContainersFullPath )
{
 
if( !MainWindow ){
  
print( "The Main Window is not defined." );
  return;
 
}
 
 
var oPaneMgr MainWindow.getPaneMgr();
 if( !
oPaneMgr ){
  
print( "The Pane Manager is not defined." );
  return;
 
}
 
 
var sPaneClass "DzContentLibraryPane";
 var 
oPane oPaneMgr.findPanesPaneClass );
 if( !
oPane ){
  
print( String("The \"%1\" class could not be found.").argsPaneClass ) );
  return;
 
}
 
 
var oContentMgr App.getContentMgr();
 if( !
oContentMgr ){
  
print( "The Content Manager is not defined." );
  return;
 
}
 
 
var oBaseFolder oContentMgr.findBaseDirectorysFullPathfalse );
 if( !
oBaseFolder ){
  
print( String("A base path for \"%1\" could not be found.").argsFullPath ) );
  return;
 
}
 
 
var sBasePath oBaseFolder.fullPath;
 
 var 
sRelPath oContentMgr.getRelativePathsFullPathfalse );
 if( 
sRelPath == sFullPath ){
  
print( String("A relative path for \"%1\" could not be found.").argsFullPath ) );
  return;
 
}
 
 
if( sRelPath.startsWith"/" ) ){
   sRelPath 
sRelPath.substring1sRelPath.length );
 
}
 
 
var oAssetMgr App.getAssetMgr();
 if( !
oAssetMgr ){
  
print( "The Asset Manager is not defined." );
  return;
 
}
 
 
var aIdPath [ oAssetMgr.getStudioDirID(), sBasePath ];
 var 
aRelParts sRelPath.split("/");
 for( var 
0aRelParts.length+= ){
  aIdPath
.pushString("%1/%2").argsBasePath ).argaRelParts.slice(01).join"/" ) ) );
 
}
 
 oPane
.browseToIDPathaIdPath );
 
oPane.updateContaineraIdPath );

The function above could then be executed with a single line, like so…

setContentLibraryNativeFormatContainer"C:/Users/Rob/Documents/DAZ 3D/Studio/My Library/Scripts/Utilities" ); 

Taking it a step further, if the function were placed in a file named “dzFavoriteFunctions.dsa” within the “./scripts/support/DAZ/ContentLibrary/” directory of your DAZ Studio 4.5 installation, you would be able to create custom actions/scripts that looked like so…

var sFavPath "C:/Users/Rob/Documents/DAZ 3D/Studio/My Library/Scripts/Utilities";
var 
sFuncPath String("%1/support/DAZ/ContentLibrary/dzFavoriteFunctions").argApp.getScriptsPath() );
var 
oScript = new DzScript();
var 
sFuncFullPath oScript.getScriptFile( sFuncPath );
if( !
sFuncFullPath.isEmpty() ){
 
include( sFuncFullPath );
 
setContentLibraryNativeFormatContainersFavPath );
else {
 
var sMessage String("A script at \"%1\" could not be found.").argsFuncPath );
 
MessageBox.informationsMessage"Resource Error""&OK;" );

... where the only part that needed to change between custom actions would be the string with the path on the first line. The same function script could then be extended to define additional functions for the other container types, and then there would be a total of two lines to change for a generated “favorite” custom action - the first line and the name of the function used in the included function script.

My point being… there is quite a bit that could be done here, even by just dissecting my examples.

-Rob

 Signature 

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

Profile
 
 
Posted: 16 October 2012 10:22 PM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRank
Total Posts:  373
Joined  2003-10-09

I didn’t respond to this earlier because I needed to get back to a few other important matters… but I wanted to say that I agree there is a general issue with menu/toolbar customizations and the ability to keep some while also benefiting from the improvements that have been made to the defaults. Its not an easy nut to crack, but I have been working on something to address it… because I do quite clearly see the need.

-Rob

 Signature 

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

Profile
 
 
Posted: 17 October 2012 07:19 AM   [ Ignore ]   [ # 12 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15674
Joined  2003-10-09

That’s encouraging. All I had been able to think of, for menus, was something like the way one can export a branch from the Windows Registry - butt hat would still need some constant way of referencing the actions used.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile