Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Pressing Set button in Hair Constraint Tag

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 506 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 30/08/2017 at 12:16, xxxxxxxx wrote:

      Hello! I'm trying to make a script that generates two nulls for a spline and attaches spline's first and last point to those nulls.

      In this topic Andreas tells to use CallButton() function, but I can't get this script to work.
      https://developers.maxon.net/forum/topic/9445/12661_clicking-set-button-of-constraint-tag-from-pygen

      The script is for Script Manager. You have to select spline object first and then run the script.

        
      import c4d  
        
      def main() :  
        doc = c4d.documents.GetActiveDocument()  
        selo = doc.GetActiveObjects(0)  
        if len(selo) > 0:  
            for o in selo:  
                    select_points = o.GetPointS()  
                    pc = len(o.GetAllPoints())  
                    select_points.DeselectAll()  
                    select_points.Select(0)  
                      
                    nulla = c4d.BaseObject(c4d.Onull)  
                    if nulla is None:  
                        return  
                    nulla[c4d.NULLOBJECT_DISPLAY] = 2  
                    nulla.SetAbsPos(c4d.Vector(o.GetPoint(0)[0],o.GetPoint(0)[1],o.GetPoint(0)[2]))  
                    nulla.SetName("A")  
                    doc.InsertObject(nulla)  
                    aTag = o.MakeTag(1018074)  
                    aTag[c4d.HAIR_CONSTRAINTS_TAG_ANCHOR_LINK] = nulla  
                    c4d.CallButton(aTag, c4d.HAIR_CONSTRAINTS_TAG_SET_ANCHOR)  
                      
                    select_points.DeselectAll()  
                    select_points.Select(pc-1)  
                    nullb = c4d.BaseObject(c4d.Onull)  
                    if nullb is None:  
                        return  
                    nullb[c4d.NULLOBJECT_DISPLAY] = 2  
                    nullb.SetAbsPos(c4d.Vector(o.GetPoint(pc-1)[0],o.GetPoint(pc-1)[1],o.GetPoint(pc-1)[2]))  
                    nullb.SetName("B")  
                    doc.InsertObject(nullb)  
                    bTag = o.MakeTag(1018074)  
                    bTag[c4d.HAIR_CONSTRAINTS_TAG_ANCHOR_LINK] = nullb  
                    c4d.CallButton(bTag, c4d.HAIR_CONSTRAINTS_TAG_SET_ANCHOR)  
        
                    o.InsertTag(c4d.BaseTag(1018068))  
        c4d.EventAdd()  
          
      if __name__ == "__main__":  
        main()  
      

      I made similar script that uses CallButton function with Spline Dynamics tag to set fixed points and it works. Weird...

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 31/08/2017 at 05:51, xxxxxxxx wrote:

        Hi,

        this got discussed just recently. Please have a look at CallButton Won't Work on new Tags.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 31/08/2017 at 08:05, xxxxxxxx wrote:

          Thank you Andreas. Now it works!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post