How can I assign a shortcut to the cloth tag when it's not in the commander?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2013   #1
How can I assign a shortcut to the cloth tag when it's not in the commander?

Hi, I'm new here I'd appreciate your help.

I spent 10 hours trying to set a shortcut to the cloth tag, but since that command is not in the command manager I can't seem to be able to do so. Is there any way to do it?

Thank a lot!
 
Old 07 July 2013   #2
Tags are not "commands" in that sense. Though I think this would be pretty neat. You can
write a script and assign this script to a short-cut.

import c4d

ID_CLOTH_TAG = 100004020

if op:
    tag = op.MakeTag(ID_CLOTH_TAG)
    doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
    c4d.EventAdd()


Edit: Improved text.
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins

Last edited by NiklasR : 07 July 2013 at 03:20 PM.
 
Old 07 July 2013   #3
Much much much appreciate Niklas...

That actually worked

It goes without saying, I'm a newbie, so, can you tell me how do you know the name of the cloth tag is CLOTH_TAG and the ID is 100004020? The reason I'm asking is because I've got some other tags I'd like to assign shortcuts to?

Thanks again Niklas!
 
Old 07 July 2013   #4
I have chosen the name ID_CLOTH_TAG myself. Most tags have a symbolic ID that can be accessed via the c4d module, but the cloth tag is not one of these.

Here's a script that will generate a script for you.

import re
import c4d

from c4d.gui import MessageDialog as MDlg

TEMPLATE = """
import c4d

TAG_ID = %s

if op:
    tag = op.MakeTag(TAG_ID)
    doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
    c4d.EventAdd()"""

def find_symbol(type_id, expr=re.compile(r'[A-Z][a-z]+')):
    for k, v in vars(c4d).iteritems():
        if type_id == v and expr.match(k):
            return k

def main():
    tag = doc.GetActiveTag()
    if not tag:
        MDlg('Select a single tag, please.')
        return

    # Search for the ID in the c4d module.
    symbol = find_symbol(tag.GetType())

    if symbol is None:
        text = TEMPLATE % tag.GetType()
    else:
        text = TEMPLATE % 'c4d.%s' % symbol

    c4d.CallCommand(13957) # Clear Console
    print text
    c4d.CallCommand(12305) # Console

main()


Select the tag you want to create a script for and take a look into your console.

Output for a Phong tag:

import c4d
TAG_ID = c4d.Tphong
if op:
    tag = op.MakeTag(TAG_ID)
    doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
    c4d.EventAdd()


And for a rigid body tag:

import c4d
TAG_ID = 180000102
if op:
    tag = op.MakeTag(TAG_ID)
    doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
    c4d.EventAdd()



Best,
-Nik
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins

Last edited by NiklasR : 07 July 2013 at 04:41 PM.
 
Old 07 July 2013   #5
I sincerely wish one day, I can help you with something. I'm so grateful.

You've saved me couple of restless nights.

BEST,
Trajko
 
Old 07 July 2013   #6
One last thing...

Hey Nik,

I was wondering if it was possible to assign a shortcut for getting into the animation layout?

Because I find myself jumping back and forth between the standard and the animation layout a lot. It would be really cool if a shortcut could be assigned.

Very best,
Trajko
 
Old 07 July 2013   #7
Hey sorovince,

sure there is. Same method: Execute the script and copy the contents of the console into a new script. The script below will ask you for a file, select the layout file *.l4d.

import os
import c4d

template = """
import c4d
flname = r%s
c4d.documents.LoadFile(flname)"""

def main():
    start = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_LIBRARY_USER  )
    flname = c4d.storage.LoadDialog(def_path=start)
    if not flname or not os.path.isfile(flname):
        return

    c4d.CallCommand(13957) # Clear Console
    print template % repr(str(flname))
    c4d.CallCommand(12305) # Console...

main()


Cheers,
-Nik
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
Old 07 July 2013   #8
Long live Nik

Hey Nik,

So sorry for my late reply, I wasn't able to respond. I still haven't tried that because I'm loggin from a different computer just so I can check

I have no doubt it will work.

Thanks again,

Best
Trajko
 
Old 07 July 2013   #9
Hey Nick,

The content of the console says...

Traceback (most recent call last):
File "'scriptmanager'", line 18, in <module>
File "'scriptmanager'", line 11, in main
NameError: global name 'os' is not defined

Am I doing something wrong?

Best,
Trajko
 
Old 07 July 2013   #10
Yup, you forgot the first line during the copy&paste.

-Nik
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
Old 07 July 2013   #11
Yup, that did it.

Best,
Trajko
 
Old 07 July 2013   #12
Maybe this is too much but I thought it's worth the shot..

Is it possible to assign a shortcut for the a certain tab?)

For example, to select the cube, and after pressing SHIFT + C for example, to be taken to the coordinates tab as shown here...

http://dangov.com/nik.png

Best,
Trajko

Last edited by sorovince : 07 July 2013 at 08:25 AM.
 
Old 01 January 2014   #13
Originally Posted by NiklasR: Here's a script that will generate a script for you.

Brilliant! Incredibly useful script, I can finally access tags quickly!
__________________
jackmyers.tv
 
Old 01 January 2014   #14
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:51 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.