1. #1

    Question Subtools and Macros

    I get the below error when I try and create a macro that imports two OBJs and puts one as a subtool... it never ends up putting the object in the subtool...

    Any ideas?


    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    Hmm... ok...

    I just tested Macros with Subtools using objects that are preloaded in ZBrush... and it worked.

    So it seems like it's something to do with objects that i've imported that is not allowing me to append a subtool.

    is there some limitation in filenames? paths? that I could be ignorant of.

    thank you
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  3. #3
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,685

    Default

    Macros can be tricky like that but the solution depends on what you are trying to do. For example, do you want your macro to give you the option of choosing the OBJs? Posting the whole macro will help as it will need editing.

  4. #4
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    Quote Originally Posted by marcus_civis View Post
    Macros can be tricky like that but the solution depends on what you are trying to do. For example, do you want your macro to give you the option of choosing the OBJs? Posting the whole macro will help as it will need editing.
    Thanks for the response. Yeah, basically I want to import two objects and make one the subtool of the other.


    It would be nice to then subdivide and create a morph target and layer but that is secondary.


    What I want hope to be able to do is run a python script on the macro that will change the imported OBJs for subsequent projects...


    When I'm around a computer I will upload a version of the script and see if anyone can make sense of it.
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Aug 2011
    Location
    Mebane, NC
    Posts
    3,044

    Default

    If the subtool was part of the project file, it would seem possible. Were you trying to bring it in from elsewhere such as a folder?

  6. #6
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    Quote Originally Posted by Doug Jones View Post
    If the subtool was part of the project file, it would seem possible. Were you trying to bring it in from elsewhere such as a folder?
    Ahh is there an issue with creating a subtool in macros. I'm trying to import 2 obj files...
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  7. #7
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,685

    Default

    Here's a macro that will do what you want, or you can adapt it to you needs. Copy the file to your ZBrush 4R4\ZStartup\Macros\Misc folder and press Macro>Reload All Macros or restart ZBrush. There will then be an AppendOBJ button in the Macro>Misc folder.

    The macro works by reading a text file. I've set this to ZBrush 4R4\ZScripts\AppendList.txt but you can change this to anything/anywhere you want by editing the fileListPath at the start of the macro. (Note though, it's probably not a good idea to store the file in the Macros folder or subfolders as ZBrush will try to load it as a macro.)

    The AppendList.txt file has the file names and full paths for the OBJs you want to use. The list is simply the file paths, on separate lines, e.g. :

    C:\Users\Marcus\Desktop\Body_1.OBJ
    C:\Users\Marcus\Desktop\leftArm.OBJ
    C:\Users\Marcus\Desktop\rightArm.OBJ

    The macro will load the first file and then append the remaining ones, so long as the files actually exist. It will append any number up to 100 OBJs, though again you can change this if you wish by editing the maxAppend number at the start of the macro.

    I've commented the macro so that anyone who's interested can see what the code is doing.

    Download macro here: AppendOBJ.txt

    HTH,

  8. #8
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    Quote Originally Posted by marcus_civis View Post
    Here's a macro that will do what you want, or you can adapt it to you needs. Copy the file to your ZBrush 4R4\ZStartup\Macros\Misc folder and press Macro>Reload All Macros or restart ZBrush. There will then be an AppendOBJ button in the Macro>Misc folder.

    The macro works by reading a text file. I've set this to ZBrush 4R4\ZScripts\AppendList.txt but you can change this to anything/anywhere you want by editing the fileListPath at the start of the macro. (Note though, it's probably not a good idea to store the file in the Macros folder or subfolders as ZBrush will try to load it as a macro.)

    The AppendList.txt file has the file names and full paths for the OBJs you want to use. The list is simply the file paths, on separate lines, e.g. :

    C:\Users\Marcus\Desktop\Body_1.OBJ
    C:\Users\Marcus\Desktop\leftArm.OBJ
    C:\Users\Marcus\Desktop\rightArm.OBJ

    The macro will load the first file and then append the remaining ones, so long as the files actually exist. It will append any number up to 100 OBJs, though again you can change this if you wish by editing the maxAppend number at the start of the macro.

    I've commented the macro so that anyone who's interested can see what the code is doing.

    Download macro here: AppendOBJ.txt

    HTH,
    Marcus that works great! Thanks a ton! I've been trying to find a way to do this for years...!

    What did you have to do in order to make it work? Or are there just a few things that don't work with macros?

    If I wanted to add a couple other functions such as set a morph target, create a couple layers and subdivide... could I just add that or would there be more i'd need to know for that as well?

    Thanks a million regardless!
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  9. #9
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,685

    Default

    Quote Originally Posted by dragotron View Post
    Marcus that works great! Thanks a ton! I've been trying to find a way to do this for years...!

    What did you have to do in order to make it work? Or are there just a few things that don't work with macros?

    If I wanted to add a couple other functions such as set a morph target, create a couple layers and subdivide... could I just add that or would there be more i'd need to know for that as well?

    Thanks a million regardless!
    It's the selecting from the pop up which is tricky. For some reason it requires a full path which is not provided when the macro is just recorded. The [IGetTitle] code corrects that.

    In general macros work very well but sometimes a little editing can make them much more useful. ZScript is not too difficult once you get started.

    I've added some new code at the end of the macro. It just runs through all the new subtools and calls a 'DoStuff' routine. You'll see this routine at the top of the macro. I've put in what I think you're after but you can edit it how you want.

    Revised macro: AppendOBJ.txt

  10. #10
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    Marcus, you understand me!

    EXACTLY what I needed it to do. I'm gonna keep developing this now! Thanks so much for your tips.

    I'd love to learn to do this stuff. Do you know of any tutorials? Building interfaces would be awesome...
    Last edited by dragotron; 10-09-12 at 02:11 PM.
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  11. #11
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,685

    Default

    I'm glad you found it useful.

    If you are interested in learning more about ZScript then the online docs has more information:
    http://www.pixologic.com/docs/index.php/ZScripting

    And you can always ask questions in this forum.

  12. #12
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    thanks.. going through the document now. It's to bad we can't use the rename function in zscript... I saw that you answered someones question about that elsewhere on this forum...

    If I wanted to import and apply a texture and displacement map would I also need the IGetTitle code to do that?

    Also, storing a morph target doesn't seem to want to work...
    Last edited by dragotron; 10-10-12 at 03:42 PM. Reason: added something
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  13. #13
    Senior Member Follow User Gallery
    Join Date
    Dec 2009
    Posts
    131

    Default

    OK, I fixed the storing morph target.. I just adjusted where it was placed in the script and voila...! Had to put it further down the stack.

    I'd love to hide the 2nd and 3rd subtool on import and load textures and displacements still tho
    ______________________________________________
    specimen12 - alien creature
    ______________________________________________

  14. #14
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,685

    Default

    To hide all but the first subtool you'd have to adjust the Loop code to this:

    [CODE] [Loop,[SubToolGetCount],//loop through all subtools
    [SubToolSelect,[Val,n]]//select each subtool
    [If,n>0,
    [VarSet,subToolPath,[IGetTitle,Tool:Item Info]]//get subtool name
    [VarSet,subToolPath,[StrExtract,subToolPath,0,[StrLength,subToolPath]-2]]//trim off period
    [IClick,[StrMerge,"Tool:Sub Tool:",subToolPath]]//turn it off
    ]
    [RoutineCall,DoStuff]
    ,n][/CODE]

    Loading textures and displacements is a bit more tricky in that you'll need to get the filenames, unless you can name them the same as your OBJs apart from a suffix and extension which you can add in code. You would use [FileNameExtract] to get the OBJ path and name without extension, then use [StrMerge] to create the new file name.

    Then you'd use code something like this at the appropriate point in the DoStuff routine:
    [CODE]
    [FileNameSetNext,#textureFilePath]
    [IPress,Texture:Import]//import texture
    [ISet,Texture:Item Info,[IGetMax,Texture:Item Info]]//select the last imported texture
    [VarSet,txtrName,[IGetTitle,Texture:Item Info]]//get the title
    [VarSet,txtrName,[StrExtract,txtrName,0,[StrLength,txtrName]-2]]//trim off period
    [ISet,Texture:Item Info,0]//turn off texture
    //assign texture to subtool:
    [IPress,Tool:Texture Map:TextureMap]
    [IClick,[StrMerge,"PopUp:",#txtrName]][/CODE]

  15. #15
    New Member Follow User Gallery
    Join Date
    Apr 2004
    Location
    Poland / UK
    Posts
    4

    Default

    Marcus maybe you will be know.

    My problem is linked up, so-so, with this above. I want to get visiblity status of subtool. And I want to set it invisible.

    I tried like this:

    [IModSet,Tool:SubTool:PM3D_Cube3D_2,17].
    17 is for visible. 1 is for invisible.

    But how i can get this information ? I tried [IModGet] but this don't work.

Page 1 of 2 12 LastLast

Posting Permissions

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