Created
May 12, 2022 11:52
-
-
Save MikeUdin/d5e243ffc84ff7288dc623c56e0275ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import c4d | |
from c4d import gui | |
# In this video let's talk how to create layers, | |
# apply it to objects and change it attributes with Cinema 4D Python SDK. | |
# Check out tutorial here: | |
# https://mikeudin.net/?p=8680 | |
def GetFirstLayer(doc): | |
return doc.GetLayerObjectRoot().GetDown() | |
def main(): | |
# Get the first document layer | |
fl = GetFirstLayer(doc) | |
if not fl: | |
gui.MessageDialog('No layers found!') | |
return | |
# Set layer data with Solo attribute, you can add any other attribute to the dict | |
# like a {'solo':True, 'visible':True,'color':c4d.Vector(1,1,1)} | |
new_layer_data = {'solo':True} | |
fl.SetLayerData(doc,new_layer_data) | |
# This isn't documented near SetLayerData, but you must call this method or C4D won't know to update the | |
# solo state of layers in the scene. | |
doc.ChangeNBit(c4d.NBIT_SOLO_LAYER, c4d.NBITCONTROL_SET) | |
# Let C4D know something has changed to trigger a redraw | |
c4d.EventAdd() | |
if __name__=='__main__': | |
c4d.CallCommand(13957) # Clear Console | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment