Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

please help me,about channel box question.

fenglelyng
Enthusiast
Enthusiast

please help me,about channel box question.

fenglelyng
Enthusiast
Enthusiast

One model's channel box is locked and hidden, but I need to copy this model, and it is a model that is not locked and hidden channel box. Actually I just don't want to go to channel control to unlock them. Is there a faster way to directly copy one?

 

 

fenglelyng_0-1680757816154.png

 

0 Likes
Reply
Accepted solutions (1)
672 Views
7 Replies
Replies (7)

amaterasu-qbb
Collaborator
Collaborator

Hi! @fenglelyng 
The only way to copy and paste the Locked and Hidden values would be to set them from Channel Control. By default.
So you need to do it another way. That is to use code.
Unfortunately, I don't have the skills to do that. So I suggest asking a similar question in the Maya Programming forum.

If for some reason you cannot ask the question, I can ask it and let you know if I get an answer, if you like.

Sorry to bother you.

0 Likes

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

Getting and setting Attributes is quite easy via code. Here is a script that does this:

import maya.cmds as mc

def tranferValuesNode():
    source = mc.ls(sl=True)[0]
    target = mc.ls(sl=True)[1]
    
    attrs = mc.listAttr(target, k= True)
    for a in attrs:
        v = mc.getAttr("{0}.{1}".format(source, a))
        print(v)
        mc.setAttr("{0}.{1}".format(target, a),v)


tranferValuesNode()

How to use it:

1) Create a Pythontab in your Script Editor

2) Copy the script into the Tab

3) Select the object you want to take the values from

4) Shift select the object you want to transfer the values to

5) Run the Script from the Script Editor

 

I hope it helps!

 

 

fenglelyng
Enthusiast
Enthusiast

is so cool.I hope learning that.thank you.

fenglelyng
Enthusiast
Enthusiast

I hope learning maya python also.how can I learning it?

Kahylan
Advisor
Advisor

A good place to start is the Maya learning channels series on it. It's a bit older, but scripting has stayed mostly the same.

 

https://www.youtube.com/watch?v=eXFGeZZbMzQ&list=PL-4p6ppgFOkWtUtcp46Z_AufwVP0CougD

 

Two tutorial series that I used to learn the proper basics are these two:

https://www.cgcircuit.com/course/learn-python-inside-maya

https://ondemand.riggingdojo.com/MayaPython101

 

Sadly both of those are quite expensive, so I would probably check youtube for free learning resources first.

amaterasu-qbb
Collaborator
Collaborator

@Kahylan .
Thank you for all your great scripts. You have always helped me. Thank you.

 

Hi! @fenglelyng .
There are many different ways to learn. Please refer to these. Search in both Python and mel as much as possible. It is difficult to think of code from scratch. Copy and paste it.

 

There are some sites you will definitely use when you are scripting. You don't have to remember them all. Search for the function you want to use here too.
You can find it quickly by using Ctrl+F and entering keywords in the browser.
https://help.autodesk.com/view/MAYAUL/2023/ENU/index.html?contextId=COMMANDSPYTHON-INDEX

Capture.PNG

There are various ways to find this site: start Maya, press F1 and help will open in your browser. You will see a scrollbar on the left-hand side.
Scroll down it and click on Technical Documentation and then Python Commands to be sure.

Of course, you can also select Technical Documentation from the list on the right-hand side.

o7.PNG

You can also choose Help>Script Reference>Python Command Reference in the Help menu on the right-hand side of Maya.

o6.PNG

If you want to look for it on the internet, search for Maya version number python reference and you will find Help Home at the top, which will take you to the same page as when you press the F1 key.
Check the version of Maya listed on the site when using it.

Tutorial videos are also available. A particularly good one is Chris Zurbrigg's tutorial. Both paid and free tutorials are available.
Click View All on Chris Zurbrigg's tutorials and try the ones at the bottom under Getting Started (free and basic).
https://zurbrigg.teachable.com/

 

Sorry. I am in Japan and only know of Japanese books. I'm sorry to trouble you, but please try to find it.

You can also use Stack Overflow.

You can ask @Kahylan in the Maya Programming forum of the Autodesk Maya Forum. I'm also in the process of learning, so let's both do our best.

fenglelyng
Enthusiast
Enthusiast

😭ok.I think if I learning that,my English level will had a big advands.😭🤣

0 Likes