Relative paths for images? (SOLVED)

HellboyHellboy Posts: 1,408

Hi.

I am including an image inside a dialog, it works fine with an absolute path but I can`t seem to find anywhere how to set a relative path for distribution purposes. This is what I have:

 

var wDlg = new DzDialog;var Label=new DzLabel(wDlg)var Image = new Pixmap("/Users/Soto/Documents/DAZ 3D/Studio/My Library/Scripts/Soto/image.png");Label.pixmap = new Pixmap(Image);var size = Image; wDlg.setFixedSize( size.width, size.height ); wDlg.exec()

 

I would appreciate a hint, I`m really not having any luck :/

Post edited by Hellboy on

Comments

  • Cayman StudiosCayman Studios Posts: 1,074
    edited May 2017

    You use getAbsolutePath() on the Content Manager object.  So you provide the path relative to the DAZ Library path and it will give you the absolute path on your computer.  Thus:

    var oContentMgr = App.getContentMgr();
    var sPath = oContentMgr.getAbsolutePath( "/Scripts/Soto/image.png", true );

    Post edited by Cayman Studios on
  • HellboyHellboy Posts: 1,408

    Thank you very, very much!

    I tried getRelativePath out of confusion at some point. This worked perfect :)

    var wDlg = new DzDialog;//Image with relative pathvar oContentMgr = App.getContentMgr();var sPath = oContentMgr.getAbsolutePath( "/Scripts/image.png", true );var Label = new DzLabel(wDlg);var Image = new Pixmap(sPath);Label.pixmap = new Pixmap(Image);//Dialog size is fixed to imagevar size = Image;wDlg.setFixedSize( size.width, size.height ); wDlg.exec()

     

Sign In or Register to comment.