1. #1
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default Retrieve full path to current material and load it

    Hi guys, how're you doing?

    I'm trying to write a simple line which allows me to load the material currently in use.
    I guess something is wrong with my code.


    [FileNameSetNext, [FileNameExtract, [IGetTitle,Material:Current Material], 7]
    [IPress,Material:Load]

    Any clue?
    Thanks a lot!
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

  2. #2
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default

    Hey guys I tried other approaches but still I can't get it to work. Today I tried this with no luck:

    [VarDef,materialPath,""]
    [VarSet,materialPath,[FileNameResolvePath, [StrMerge,[IGetTitle,Material:Current Material], .ZMT] ]
    [FileNameSetNext, [Var,matPath]][IPress,Material:Load]
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

  3. #3
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    IGetTitle doesn't return a file name or path for the Material palette, only the button path. You can't get the material file location using zscript.

  4. #4
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default

    Hey Marcus thanks for the reply. Do you think is there any other way I can re-load or default the currently used material through Zscript?
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

  5. #5
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    It depends a bit on what you are trying to do. Could you explain why you want to reload a material that's already loaded?

  6. #6
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default

    Yes, it's for a little script I'm writing.

    Sometimes you end up modifying a material by playing with lightcaps or tweaking the material modifiers, etc. So loading back the active material it's the quickest way I was thinking to reset it to its default values.
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

  7. #7
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Well, there are some regular folders that you could search easily enough. Then if you didn't find the material there you could inform the user and get them to select the material from disk (you could use FileNameAsk for that). The code below shows you the idea. Note that LightCaps are a bit more tricky though...




    [VarDef,gStartupFolder,"ZBRUSH_ZDATA/Materials/Startup/"]
    [VarDef,gMatcapFolder,"ZBRUSH_ZDATA/Materials/MatCap/"]
    [VarDef,gUserFolder,"ZBRUSH_ZSTARTUP/Materials/"]
    [VarDef,gLightboxFolder,"ZBRUSH_ZMATERIALS/"]


    [IButton,"Reset mat","Reset the current material",
    [VarSet,lCurrentMat,[StrMerge,[IGetTitle,Material:Current Material],".zmt"]]
    [VarSet,loadOK,0]
    [Loop,1,
    [VarSet,mat,[StrMerge,gStartupFolder,lCurrentMat]]
    [If,[FileExists,mat],[VarSet,loadOK,1][LoopExit]]
    [VarSet,mat,[StrMerge,gMatcapFolder,lCurrentMat]]
    [If,[FileExists,mat],[VarSet,loadOK,1][LoopExit]]
    [VarSet,mat,[StrMerge,gUserFolder,lCurrentMat]]
    [If,[FileExists,mat],[VarSet,loadOK,1][LoopExit]]
    [VarSet,mat,[StrMerge,gLightboxFolder,lCurrentMat]]
    [If,[FileExists,mat],[VarSet,loadOK,1][LoopExit]]
    ]
    [If,loadOK,
    [FileNameSetNext,mat]
    [IPress,Material:Load]
    ,//else not found
    [Note,"Material not found. Please load file from disk"]
    ]
    ,,1]

  8. #8
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default

    Marcus you've been tremendously helpful and that's really clever.

    I'd like to include your lines in a script I'm about to post for free on the forums. I'd obviously give you the necessary credits.
    Would you authorize me to do that?
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

  9. #9
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Yes, of course. It's kind of you to ask. For anyone reading this, they are free to use any code I post.

  10. #10
    Member Follow User Gallery
    Join Date
    Jun 2013
    Location
    London
    Posts
    60

    Default

    Thanks Marcus,
    this is the link to the plugin http://www.zbrushcentral.com/showthr...v1-0&p=1174708

    it's very simple but hopefully handy
    Character Artist @ Bohemia Interactive
    www.rodolfofanti.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •