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

    Link not connecting

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 490 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 16/10/2012 at 10:38, xxxxxxxx wrote:

      My goal is to control a null on a user specified spline with an align to spline tag on a null.  My problem is that the linking isn't working.  When I make my object plugin editable the null object snaps to the test spline that I had placed into the link box in my plugin.  Why does this only work when I make my object plugin editable?  This is my first plugin by the way.  Here is the code:

      CABLEPATH_LINK = 11010,
      PERCENT_PATH = 11011
        
        
      class Test(c4d.plugins.ObjectData) :
        
          def __init__(self) :
              self.SetOptimizeCache(True)
        
          def Init(self, op) :
              self.InitAttr(op, float, [PERCENT_PATH])
              op[PERCENT_PATH] = 0
              return True
        
          def GetVirtualObjects(self, op, hierarchyhelp) :
              doc = c4d.documents.GetActiveDocument()
              myData = op.GetDataInstance()
        
              pathDist = myData.GetReal(PERCENT_PATH)
              pathLink = myData.GetLink(11010)
              baseNull = c4d.BaseObject(c4d.Onull)
              myPathNull, alignT = self.PathNull(op, pathLink, pathDist)
              myPathNull.InsertUnder(baseNull)
        
              return baseNull
        
          def PathNull(self, op, pathLink, pathDist) :
              pNull = c4d.BaseObject(c4d.Onull) #Create new null
              alignT = pNull.MakeTag(c4d.Taligntospline)
              alignT[c4d.ALIGNTOSPLINETAG_TANGENTIAL] = True
              alignT[c4d.ALIGNTOSPLINETAG_LINK] = pathLink
              alignT[c4d.ALIGNTOSPLINETAG_POSITION] = pathDist/10
              return pNull, alignT
        
      if __name__ == '__main__':
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 16/10/2012 at 11:12, xxxxxxxx wrote:

        The align to spline tag is an expression tag, meaning that it's executed every frame. But what you're doing is creating a virtual tag each frame which only exists at that point, so the tag is never executed. The moment you make it editable the tag can be executed and it works as expected.

        What you should do instead is attach an align to spline tag to your generator object in the OM. You can set the tag's values from within your plugin if you want to - e.g. when the user drops a spline into the link field, set that spline in the corresponding field in the tag. The tag will execute each frame, treat the generator's output as a null and move it along the spline.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 16/10/2012 at 13:51, xxxxxxxx wrote:

          Thanks for the explanation and tip Spedler!  Though the idea of attaching a tag to the generator object seems like it would work, I'm considering a cleaner way instead of relying on the tag to give me the path and animatable position.  After reading Rui Batista's recent post (Limit at 512), I may have enough info now to get a spline (dropped into a link field) and all of it's info (length, and any point at a designated percentage along the spline).  I'm using the animated null just to give me position data to animate objects before and after it along the spline with all the settings applied by the user.

          If you have any more tips on a spline matrix not already stated in Rui's post or within some other post or link, I would definitely appreciate it.

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 16/10/2012 at 16:02, xxxxxxxx wrote:

            Here is my current solution edit for getting a null object linked to and controlled along a spline.:

                myData = op.GetDataInstance()
                offset = myData.GetReal(PERCENT_PATH) #PERCENT_PATH is the variable controlled by a slider.
                self.PathNull(op, pathLink, offset)
              
                def PathNull(self, op, pathLink, offset) :
                    pNull = c4d.BaseObject(c4d.Onull) #Create new null
                    if pathLink != None:
                        real_spline = pathLink.GetRealSpline()
                        sh = c4d.utils.SplineHelp()
                        sh.InitSpline(real_spline,c4d.Vector(0),None,True,True,True,True)
                        spLen = sh.GetSplineLength()
                        pos = sh.GetPosition(offset)
                        pNull.SetAbsPos(c4d.Vector(pos))
                    return pNull
            

            Now it's time to go figure out the whole angle tangent bit.  I think I see Scott Ayers and Deep Shade explaining it over at CGTalk('Python - align to spline' post).

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