Results 1 to 11 of 11

Thread: Accessing keys of a Curve Node

  1. #1

    Accessing keys of a Curve Node

    Hello Guys,
    I tried to google this up but couldn't find any reference, so the question is:
    How do I access envelopes/channels of a node, namingly the envelopes of a Curve node created inside the Displacement node editor?
    Is it possible at all?
    Thanks in advance for any answer.

  2. #2
    Registered User Diepgroen's Avatar
    Join Date
    Jul 2016
    Location
    Amsterdam
    Posts
    28
    I think most if not all channel envelopes can be accessed through Python. But I might be wrong.
    If you can activate the envelope i think LWPython can access it, read it and manipulate it. I find it really tricky though.

    You will need to make use of these functions and classes:

    classes

    Code:
    lwsdk.LWInterfaceInfo()
    lwsdk.LWItemInfo()
    lwsdk.LWChannelInfo()
    lwsdk.LWEnvelopeFuncs()
    functions/ methods

    Code:
    lwsdk.LWInterfaceInfo().selected_items()
    lwsdk.LWItemInfo().chanGroup()
    lwsdk.LWChannelInfo().nextGroup()
    lwsdk.LWChannelInfo().channelName()
    LWEnvelopeFuncs() has about 21 methods to work with. With these you can read and manipulate the keys and tailor your script to your needs.

    The tricky part is getting to the value you want to manipulate, which in your case is the curve node envelope value. Using the lwsdk.LWItemInfo().chanGroup() and lwsdk.LWChannelInfo().nextGroup() is the key to travel down the subgroup list.

    Image

    Click image for larger version. 

Name:	Screen Shot 2017-03-19 at 02.14.10.png 
Views:	8 
Size:	11.8 KB 
ID:	136309

    Object.CurveNode.CurveRed.Key.Value


    you will need to loop through 3 subgroups in this example:

    Code:
    SelectedObject = lwsdk.LWInterfaceInfo().selected_items()
    
    for x in range(0, len(SelectedObject)):
    	channelGroup = lwsdk.LWItemInfo().chanGroup(selectedObject) #object
    	channelGroup = lwsdk.LWChannelInfo().nextGroup(channelgroup, None) #subgroup CurveNode
    	channelGroup = lwsdk.LWChannelInfo().nextGroup(channelgroup, None) #subgroup CurveRed
    	channelGroup = lwsdk.LWChannelInfo().nextGroup(channelgroup, None) #subgroup Key
    	channel = lwsdk.LWChannelInfo().nextChannel(channelgroup, None) #subgroup Value
    	channelName = lwsdk.LWChannelInfo().channelName(channel)
    	
    	while channel != None:
    		channelName = lwsdk.LWChannelInfo().channelName(channel)
    		
    		if channelName == "Value":
    			# your magical script here
    			
    		channel = lwsdk.LWChannelInfo().nextChannel(channelgroup, channel) #subgroup Value

    Hope this gets you on the right track.

  3. #3
    Thanks a lot, I give it a try.

  4. #4
    I can reach now the Curve node inside the displacement. I want to control the Curve keys using a few Nulls so I don't have to setup expressions

    Code:
    def findEnv(self, itemType):
    		id = lwsdk.LWItemInfo().first( itemType, None )
    		groupID = lwsdk.LWItemInfo().chanGroup( id )
    		parent = None
    		while groupID:
    			if groupID != None:
    				groupName = str ( lwsdk.LWChannelInfo().groupName(groupID) )  #group name
    				print ("groupID: " +  groupName)
    				if 'Curve' in groupName:
    					print 'Curve node'
    					chan = lwsdk.LWChannelInfo().nextChannel(groupID,parent)
    					while chan:
    						channelName = lwsdk.LWChannelInfo().channelName(chan)
    						nextchan = lwsdk.LWChannelInfo().nextChannel(groupID, chan)
    						print("channelName:" + channelName)
    						chan = nextchan
    					
    			nextid = lwsdk.LWChannelInfo().nextGroup(groupID,parent) 
    			parent = groupID
    			groupID = nextid
    
    					
    		chinfo = lwsdk.LWChannelInfo()
    		chan = chinfo.nextChannel(groupID, None)
    		while chan:
    			channelName = chinfo.channelName(chan)
    			nextchan = chinfo.nextChannel(groupID, chan)
    			print("channelName:" + channelName)
    			chan = nextchan

  5. #5
    Quote Originally Posted by bazsa73 View Post
    I want to control the Curve keys using a few Nulls so I don't have to setup expressions
    What do you mean? How would you control the envelope without an expression? And further control specific keyframes?
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  6. #6
    Quote Originally Posted by ernpchan View Post
    What do you mean? How would you control the envelope without an expression? And further control specific keyframes?
    I dont want to write for each frigging key in the curve an expression. I want one master expression which handles all the keys in the curve.

  7. #7
    Registered User Diepgroen's Avatar
    Join Date
    Jul 2016
    Location
    Amsterdam
    Posts
    28
    Quote Originally Posted by bazsa73 View Post
    I dont want to write for each frigging key in the curve an expression. I want one master expression which handles all the keys in the curve.
    If I understand correctly, you would like to attach an expression the old-fashioned way (in the Expressions tab in the Graph Editor) to all selected keys in a single-shot? I don't really see any information how to attach expressions directly to the expressions tab in the graph editor. But than again you can write clever code in python to do all this. But there are no examples of this. It's up to you i think to come up with something like that, Told you it was tricksy

  8. #8
    Registered User Diepgroen's Avatar
    Join Date
    Jul 2016
    Location
    Amsterdam
    Posts
    28
    If I understand correctly, you would like to attach an expression the old-fashioned way (in the Expressions tab in the Graph Editor) to all selected keys in a single-shot?
    Correction: sorry i meant, expressions get attached to channels not keys.

  9. #9
    Quote Originally Posted by Diepgroen View Post
    If I understand correctly, you would like to attach an expression the old-fashioned way (in the Expressions tab in the Graph Editor) to all selected keys in a single-shot? I don't really see any information how to attach expressions directly to the expressions tab in the graph editor. But than again you can write clever code in python to do all this. But there are no examples of this. It's up to you i think to come up with something like that, Told you it was tricksy
    I tell you my problem first which has started this whole issue. I do this video mapping on a building, it is very wide.
    I build geometry on the existing geometry from several parts and I use DPkit part move on it to do different motion graphic stuff. I control the parts via Curve nodes.
    Typically one curve contains 4 keys at least and each key has a position and a value envelope. That's already 8 things to control. I want to write a script which handles
    this for me. Let's say some sort of master plugin which evaluates on a per frame basis and adjusts the keys accordingly.

  10. #10
    Registered User Diepgroen's Avatar
    Join Date
    Jul 2016
    Location
    Amsterdam
    Posts
    28
    Quote Originally Posted by bazsa73 View Post
    I tell you my problem first which has started this whole issue. I do this video mapping on a building, it is very wide. I build geometry on the existing geometry from several parts and I use DPkit part move on it to do different motion graphic stuff. I control the parts via Curve nodes.
    Typically one curve contains 4 keys at least and each key has a position and a value envelope. That's already 8 things to control. I want to write a script which handles this for me. Let's say some sort of master plugin which evaluates on a per frame basis and adjusts the keys accordingly.
    Quote Originally Posted by bazsa73 View Post
    I tell you my problem first which has started this whole issue. I do this video mapping on a building, it is very wide.
    I build geometry on the existing geometry from several parts and I use DPkit part move on it to do different motion graphic stuff. I control the parts via Curve nodes. Typically one curve contains 4 keys at least and each key has a position and a value envelope. That's already 8 things to control. I want to write a script which handles this for me. Let's say some sort of master plugin which evaluates on a per frame basis and adjusts the keys accordingly.
    I won't be much help to you at my level of coding, sorry.

    At least we know now that it's not about the Expressions Tab and attaching literal LWExpressions via Python. Because i think that part was not possible to my knowledge. But at least you got the channel you where looking for. Hope you can figure it out. If you do, let us know how you solved this problem.

  11. #11
    Quote Originally Posted by Diepgroen View Post
    I won't be much help to you at my level of coding, sorry.

    At least we know now that it's not about the Expressions Tab and attaching literal LWExpressions via Python. Because i think that part was not possible to my knowledge. But at least you got the channel you where looking for. Hope you can figure it out. If you do, let us know how you solved this problem.
    Thanks for your efforts dude. Maybe this is just way too difficult issue to deal with but I dont give up on it. Thanks again.

Bookmarks

Posting Permissions

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