(SOLVED) Help with App.showURL for opening local files

Lissa_xyzLissa_xyz Posts: 6,116

I have a userguide in the same folder I'm trying to call it from in the content library. This is what's in the dsa:


// DAZ Studio version 4.6.2.23 filetype DAZ Script

App.showURL( "file://Userguide.pdf" );

From what I've found, this should work for a local file. I can do online urls all day, but local files are giving me headaches.

Can someone please save my sanity? lol

Post edited by Lissa_xyz on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited October 2013

    Does this help? http://www.daz3d.com/forums/viewreply/423002/ . Though it may be your path that's at fault - you need an absolute path, not a relative path, for the App.show functions.

    Post edited by Richard Haseltine on
  • Lissa_xyzLissa_xyz Posts: 6,116
    edited October 2013

    Does this help? http://www.daz3d.com/forums/viewreply/423002/ . Though it may be your path that's at fault - you need an absolute path, not a relative path, for the App.show functions.

    I was afraid you were going to say that. lol

    The script you pointed me to works to open the current directory (just like right click > browse to folder location), but just like the previous, it doesn't open the file itself, even if using relative or absolute. I was hoping to get away with using a relative path though since not everybody will have "F:\My Freebies\Plasmaball\Shader Presets\Vaskania\Plasmaball" lol

    If using relative isn't possible, I suppose I could just put an info.duf.png with instructions labeled on it to right click > browse to view the userguide.

    Post edited by Lissa_xyz on
  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited December 1969

    If the script is going to run from the folder with the pdf you can use getScriptFileName() to get the current location, trim it back to the path, and then add the pdf name.

  • Lissa_xyzLissa_xyz Posts: 6,116
    edited October 2013

    Not a clue how to do that. lol I never stuck with learning javascript.

    I have the SDK docs, and found the function, but I can't find any examples of how to use it.


    /edit
    Could getAbsolutePath() or getFullPath() do what I need? When I attempt them, I get variable not found errors, but I'm not sure I'm even using them right. lol

    /edit 2
    Found and tried this, and created a dummy index.html. Syntax error. I'm assuming it no longer works since it says 'void' next to it in the SDK docs.

    // open a local html file in the user's browser
        dzApp->showURL( "file://" + dzApp->getDocumentationPath() + "index.html" );
    

    /another edit
    Egad, ok, I'm done with experimenting and waiting for you. I've somehow managed to create a script that continuously launches an infinite number of Daz Studios that you cannot stop, forcing you to restart. LOL

    Post edited by Lissa_xyz on
  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    The [plugin] SDK docs are not really going to help you if you don't know the differences between ECMAScript, QtScript, DAZ Script and C++. The syntax you have there is C++. The equivalent, except to a path that actually ships with the application, in DAZ Script would be:

    App.showURL( String("file:///%1/DAZ Studio/what_is_studio.htm").arg( App.getDocumentationPath() ) );

    In this example, I use String.arg() to construct a string that represents a URL using the file URI scheme, where "%1" is replaced by the base path being passed to the arg function.

    The solution that Richard describes, using your description of a pdf in the same folder [with the same name], looks like this:

    // Create a file info object, using the path of the current script
    var oFileInfo = new DzFileInfo( getScriptFileName() );
    // Prompt the operating system to do whatever it does with the given file type; same path/name as script
    App.showURL( String("file:///%1/%2.pdf").arg( oFileInfo.path() ).arg( oFileInfo.baseName() ) );

    -Rob

  • Lissa_xyzLissa_xyz Posts: 6,116
    edited October 2013

    Yea I never did get into much programming. I taught myself to write html/css and maintain/edit/create php coding and mysql databases with a splash of perl thrown in for certain scripts, and that was about it. With languages I don't know, I have an easier time reading and interpreting what's already written as opposed to writing it. I miss coding in any form, but it's been so long I have no idea where to start anymore.

    That 2nd code works perfectly for what I'm looking for. Thanks. :)

    One question, I get that the var oFileInfo is creating a function (oFileInfo) for the subsequent code, but what is the 'new' for? Is that to create a class that doesn't exist (DzFileInfo- couldn't find it in the listing), and because getScriptFileName is part of DzScriptContext, making it a global string, you were able to define a new class for it?

    Post edited by Lissa_xyz on
  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    The new operator instantiates (creates an instance of) the class/object that follows it. "var oFileInfo =" is assigning the result of that operation to a variable, so that we can access the object instance that is created. Each script is executed within a context, a DzScriptContext instance. The methods on DzScriptContext are therefore provided as functions in the global scope of the script/context; this means that they don't need to be preceded by anything - DzScriptContext is assumed. Thus getScriptFileName() returns the [full] filename of the currently running script. This path is passed to the DzFileInfo constructor in order to initialize it for that particular file... so we can get information about the file, like its [directory] path and [file] basename.

    The DAZ Studio 4.x Scripting docs are in the midst of a [very long] conversion process, which I work on in my "spare" time; i.e. nights/weekends that are not consumed by other projects/priorities. Needless to say, in their current state, they are but a skeleton of what will eventually be. I only recently started populating the Object Index within the last few weeks. In light of this, quite a while ago I made the DAZ Studio 3 scripting docs available here, rather than letting them follow DS3 into retirement. Much of the DS3 API is the same in DS4, so a significant portion of that documentation still applies - geometry related areas being of the more significant differences. In that documentation you'll notice a much larger list of classes/objects.

    -Rob

  • Lissa_xyzLissa_xyz Posts: 6,116
    edited December 1969

    Thank you! The language reference in the DS3 API docs is exactly what I was hoping for (either I'm blind, or those aren't in the 4.5 version).

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited December 1969

    As Rob said, the 4.5 version is only starting to appear - in fact I didn't realise he had started to populate it (thank you for doing so, Rob). The DS3 docs are useful for a lot of things, though there have been changes which can trip us up.

  • Lissa_xyzLissa_xyz Posts: 6,116
    edited December 1969

    I was referring more to the downloaded docs. The 4.5+ docs I downloaded through DIM doesn't have the Language Reference, but the online version of the 4.5+ docs apparently does.

    I'll have to keep an eye on the online version as I didn't know it was different than the downloaded version.

  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    Hello,
    I know this is an old topic but...
    I'm making a pretty complicated product, and I'd really like to add documentation in the main directory, as a pdf tutorial file.
    For now the only solution I found so that people can load the pdf directly from the content library is this script shared in this topic.
    I tried this and... it works like a charm!!!
    So my question is : Am I allowed to re-use this script to load my help files via my content directory?
    Thanks in advance for your inputs on this subject!

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    Yes, you are free to use the examples that I post in the forums in your own projects unless I state otherwise. In the case of forum posts, a nod in the direction of the source is appreciated, but not required*. The samples I post to the Documentation Center fall under the license linked at the top of the Scripting Samples page. All other content on the Documentation Center falls under the CC Attribution 3.0 Unported license, as posted in the footer of every page.

    *FWIW: I'm human. Courtesy and respect go a long way. A lack of it has the tendency to do the opposite. Blatant disregard for it... ensures that I use my "spare" time to help someone else.

    -Rob

  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    rbtwhiz said:
    Yes, you are free to use the examples that I post in the forums in your own projects unless I state otherwise. In the case of forum posts, a nod in the direction of the source is appreciated, but not required*. The samples I post to the Documentation Center fall under the license linked at the top of the Scripting Samples page. All other content on the Documentation Center falls under the CC Attribution 3.0 Unported license, as posted in the footer of every page.

    *FWIW: I'm human. Courtesy and respect go a long way. A lack of it has the tendency to do the opposite. Blatant disregard for it... ensures that I use my "spare" time to help someone else.

    -Rob

    Thanks a lot! I want to ... cc3 you.. Well I guess cc3 is not a verb...
    I think that's not only important but also normal to do so because it is ... just ...."Courtesy and respect"...
    Well I'd like to mention you as the origin of the code, how do you prefer me to do that? Can I include the link to this forum page in the dsa file calling the document as well as your name, or do you prefer another way to do that?

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    You're welcome. A comment linking back to this thread, or the post with the code is great.

    Ultimately, my goal is to spread the knowledge... and the history along with it. I enjoy helping people [who are appreciative of it]. I want to make it easier for the next guy/gal, so that they can focus their energy on bigger and better things. We all stand on the shoulders of those that came before us.

    -Rob

Sign In or Register to comment.