Jump to content

Sign in to follow this  
TheJimReaper

Buttons for Layout!

Recommended Posts

Hi Guys

 

I've created a sphere which I'll be using a lot. How do I go about creating a button for it to add to my layout, so I can just click the button and it appears without me having to go searching through my files hunting for it every time I need it? Is there a tutorial somewhere for doing this kind of thing?

 

Cheers

 

Jim

Share this post


Link to post

You can either go to Attribute manager - Edit menu and use Set As Default command.. or you can create a script and then drag it's icon into the layout. Layout then, needs to be saved.
5b2bdd21d675a_attributesdefault.thumb.jpg.2356a4251014401a04e8876099876409.jpg
lovelySphere.thumb.jpg.dfa94d612e74cf80cde5eb2b19796db9.jpg

Share this post


Link to post
  • Topic Author
  • Don't think the first option will work as I've made this sphere from scratch, so can't save as default.  Could do it with the a script, but I wouldn't have a clue how to do that! In all the years I've been using C4D it's one area I never touched.

     

    My Sphere.jpg

    Share this post


    Link to post

    Sorry, my bad - I didn't get you. I thought you meant a primitive sphere object with different parameters then default. In this case non of those methods will work. You would need a script that finds your scene file, opens it /merges. Then you could attach it as a button to the layout.

    Share this post


    Link to post

    Why searching for scene, create object preset...

    Then add nice "callcommand" :) script, add rendered image as icon, add to layout, done...

    Share this post


    Link to post

    To be more exact

    1,  create object, create new material (with picker select color as some primitive object/or any color you want), apply to object, set render setings to 600*600 (for rendering icon), select object, press "O" (frame object to viewport for nice icon)

     

    2, select object in OM, then File/Save Object Preset, set nice name...

     

    3,Delete object in OM

     

    4, open Script Log

     

    5, in OM File/Load Object Preset/User/Objects/***MySuperCoolObject***

     

    6, when loaded your preset object, you can see in script log line like this

        ///// c4d.CallCommand(300000111, 1121) # Load Object Preset /////

       This is command for calling your object presset, select and copy this line for later use

     

    7, Close script log and delete object from OM (to be clear only, but not needed)

     

    8, open Script Manager, then File/New

       (Python script ofcourse, you can see this script

     

    /////////

    import c4d
    from c4d import gui
    #Welcome to the world of Python


    def main():
        gui.MessageDialog('Hello World!')

    if __name__=='__main__':
        main()

    /////////

     

    9, select and remove/rewrite line " gui.MessageDialog('Hello World!') " with copied text from script log window

     

    10, your script now looks like

       /////

    import c4d
    from c4d import gui
    #Welcome to the world of Python


    def main():
       c4d.CallCommand(300000111, 1121) # Load Object Preset

    if __name__=='__main__':
        main()

    //////

     

    11, when you press "Execute", new object will be loaded

     

    12, Now it´s time for creating nice icon. If object is framed/rotated as you wish for icon, in Script Manager File/Render Icon.

     (You can see icon created for this script, if it´s too small, adjust in viewport and use this command again until satisfied.

     

    13, Script Manager/File/Save all and save script under name you wish

     

    14, When close everything and clear OM, when you go to Scripts and run your script, object appear in OM...

     

    15, Adding script to layout is just few clicks

         - right click on any pallete/Customize palettes

         - in name filter enter name of script

         - drag object to palette where you want, save layout...

     

     

    btw, if you store object preset together with material, everytime when called script also new mat will be created (if not needed, remove mat before storing object as preset

     

    Share this post


    Link to post
  • Topic Author
  • Thanks @bezofor putting all that down, not sure what when wrong though as when I hit execute nothing happened! I copied and pasted what you had written above into the script mgr and pasted in the line from the script log, but as it is now nothing happens!!

     

    In the line where it says 'if __name__==' should I have changed that to say the name of my object?

     

    Cheers 

    Jim

    Untitled-1.jpg

    Share this post


    Link to post
  • Topic Author
  • Just realised I did mine in the coffee window and not the python window! However when I redid it in the python window it still didn't work!

     

    Just done some messing about with bits, such as deleting the \\\\\\ and have now got it working and have added it to my layout.

     

    Thanks for all the help, much appreciated.

     

    Jim

    Share this post


    Link to post

    I´m glad it works for you now...

    With slashes I wanted to separate text between reply and code part only, I apologise it was bit confusing for you...

    Share this post


    Link to post

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...