Jump to content
Info News:
  • C4D Cafe 2.0 COMING SOON!

Sign in to follow this  
airbusch

Python for Spline Sequence

Recommended Posts

1462422427_MoveUpSequence.png.7147e18c983b1e5a720e4213d635ae29.png

So, what I would like to be able to do, is drag a spline into the top field, then be able to have a python script that would reference that spline and allow me to "move up sequence" using the float control. I know that I can access the "move up and down spline sequence" controls from the Mesh>Spline drop down menu, but I want to be able to control this with Xpresso which would allow me to always come back to the "exact" sequence based on the number in the float control. I can do the Xpresso, but I have no skill with Python. I was able t find this:  "c4d.CallCommand(12563) # Move Up Sequence", but have no idea how to utilize it the way I want to or make use of it with the Python node.

 

Any help would be appreciated! Thanks!

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
  • Topic Author
  • Thanks, Hrvoje, but I think I may not have made myself clear. I have no idea how to write Python code and wouldn't have a clue as to where to start with the info you referenced.

     

    Best

    Lonnie

    Share this post


    Link to post
    Share on other sites

    I see. Can you say what is it for? Maybe there is another, non python approach? :)


    Free C4D trainings from MAXON professional on our youtube channel

     

    https://www.youtube.com/c4dcafe

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • I have kind of exhausted all non-python solutions, and I'm not even sure it can be done with Python, though I believe it could. It's a very simple rig actually, using a cloner to clone several different but unique objects onto a spline. For instance, the cloner has seven unique objects and the spline has seven points. When I clone the objects onto the spline at the vertices in Iterate mode, I get seven unique objects in the exact position I want them in. Perfect.

     

    However, once they are cloned to the spline, the only way to move them and get some degree of control over them is to move the spline sequence either forward or backward. And I can do all that with the Move Sequence commands under Mesh. But, I would like that "command" to be controlled by the "float control" so that I can easily return to the starting position, or to move the sequence to position "3" for instance on the float control and get the exact same result each time. As you know, once you've hit that "Move"Sequence" command a couple of times, you have no idea where you are anymore.

     

    This is nothing complex, but I have explored all the effectors and nothing will move the cloned objects except for when the Cloner is set to "Random," then I get the Seed Control, which would be perfect except for the fact that for whatever reason, when you set the Cloner to Random, the cloner "Repeats" objects while ignoring the other unique objects in the cloner. So I end up with only 4 unique objects while C4D ignores the other 3. Not sure why this functionality cannot be undone as it makes no sense to not show all the objects in the cloner just in different positions on the spline. And if you know how to override this strange behavior of Random mode, my problem is solved.

     

    Believe me, I have been working on this for some time and even thought about creating a script to move the spline sequence, but that would be no more helpful than using the controls under Mesh. I would still not be able to select an exact sequence to the spline to have the objects in the positions I want them. And of course I can move the objects around in the cloner, but that is not a very eloquent solution, though it works to "randomize" their positions on the spline vertices while showing all unique objects in cloner.

     

    Hope that helps you to understand my problem, but i feel it could be solved with Python. That there is no easier solution to this in Cinema is a mystery.

    Randomize Objects on Spline.c4d.zip

    Share this post


    Link to post
    Share on other sites

    Any chance you have R20? With Fields this would be quite easy. If not you can still do it without Python but it will be more complicated. Have a look at the attached scene. I am using a formula effector that has "modify clone" set to 100% in the parameter tab. That allows you to control which child of the cloner is being cloned. The formula divides index by clone count, offsets it using the frequency variable and uses modulo to remap the output range to 0-1. For convenience I've added User Data, linked it to the frequency and exposed it as a HUD element. 

     

     

    Randomize Objects on Spline_NoPy.c4d

    Share this post


    Link to post
    Share on other sites
  • Topic Author
  • Havealot, what a creative use of the formula effector! Thanks so much. I did have someone send me a Python solution that works a charm and that I am going to use, but your solution is much appreciated! Thanks so much.

     

    best

    Lonnie

    Share this post


    Link to post
    Share on other sites

    Great to see a lot of out of the box and clever solutions.The easiest way here is to change spline interpolation (to linear ) or just change intermediate points to natural. Then clone onto spline in count mode where count is equal to clone count. This will set your clones to vertices and you have all the controls you want to shift clones in cloner :)


    Free C4D trainings from MAXON professional on our youtube channel

     

    https://www.youtube.com/c4dcafe

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.
    Note: Your post will require moderator approval before it will be visible.

    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  

    ×
    ×
    • Create New...