Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    AttributeError: 'list' object has no attribute 'FindTrack'

    Cinema 4D SDK
    3
    10
    1.6k
    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.
    • A
      andmotion
      last edited by Manuel

      Hi, I am trying to transfer pos of one obj on the other obj but I am getting this error AttributeError: 'list' object has no attribute 'FindTrack'

      I am not sure how to sort it out.
      Thanks for any help

      import c4d
      #Welcome to the world of Python
      
      desc_x = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0),
                          c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL, 0))
      
      desc_y = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION,c4d.DTYPE_VECTOR, 0),  
                          c4d.DescLevel(c4d.VECTOR_Y, c4d.DTYPE_REAL, 0))
          
      desc_z = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0),
                          c4d.DescLevel(c4d.VECTOR_Z, c4d.DTYPE_REAL, 0))
      
      def createPositionTracks(object):
          
          trackPosX = object.FindTrack(desc_x)
          trackPosY = object.FindTrack(desc_y)
          trackPosZ = object.FindTrack(desc_z)
          
          
          if trackPosX is None:  
              track = c4d.CTrack(object, desc_x)
              object.InsertTrackSorted(track)
              
          if trackPosY is None:  
              track = c4d.CTrack(object, desc_y)
              object.InsertTrackSorted(track)
              
          
          if trackPosZ is None:
              track = c4d.CTrack(object, desc_z)
              object.InsertTrackSorted(track)
              
      def setPositionKey(object, time, pos):
          
          trackPosX = object.FindTrack(desc_x)
          trackPosY = object.FindTrack(desc_y)
          trackPosZ = object.FindTrack(desc_z)
          
          curvePosX = trackPosX.GetCurve()
          curvePosY = trackPosY.GetCurve()
          curvePosZ = trackPosZ.GetCurve()
          
          keydict = curvePosX.AddKey(time)
          key = keydict["key"]
          key.SetValue(curvePosX,pos.x)
         
          keydict = curvePosY.AddKey(time)
          key = keydict["key"]
          key.SetValue(curvePosY,pos.y)
         
          keydict = curvePosZ.AddKey(time)
          key = keydict["key"]
          key.SetValue(curvePosZ,pos.z)
          
          return True
          
      def main():
          
          source = [c4d.ID_USERDATA,1]
          target = [c4d.ID_USERDATA,2]
          offset = [c4d.ID_USERDATA,3]
          
          if source is not None and target is not None:
              t = doc.GetTime()
              createPositionTracks(target)
              setPositionKey(target,t,source.GetAbsPos() + offset)
              
      
      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        well, that means that you try invoke FindTrack() on a list object, which will cause the exception, as the list type has no method called FindTrack(). I assume you meant to call BaseList2D.FindCTrack() ?

        Apart from that typo in the method name, you also wrote target = [c4d.ID_USERDATA,2] where you probably meant to write target = some_node[c4d.ID_USERDATA,2], which makes target a list and not a BaseList2D as you probably intended.

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • A
          andmotion
          last edited by

          Hi Zipit,

          Thanks for reply. Yes I have made a mistake typing FindTrack(). It should be FindCTrack().
          Can you explain what do you mean by some_node?
          Thanks again:)

          1 Reply Last reply Reply Quote 0
          • A
            andmotion
            last edited by

            when I having target = op[c4d.ID_USERDATA,2] it;s coming with this error : AttributeError: parameter access failed

            1 Reply Last reply Reply Quote 0
            • A
              andmotion
              last edited by Manuel

              Ok I figured it out 🙂

              import c4d
              #Welcome to the world of Python
              
              desc_x = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0),
                                  c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL, 0))
              
              desc_y = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION,c4d.DTYPE_VECTOR, 0),  
                                  c4d.DescLevel(c4d.VECTOR_Y, c4d.DTYPE_REAL, 0))
                  
              desc_z = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, c4d.DTYPE_VECTOR, 0),
                                  c4d.DescLevel(c4d.VECTOR_Z, c4d.DTYPE_REAL, 0))
              
              def createPositionTracks(object):
                  
                  trackPosX = object.FindCTrack(desc_x)
                  trackPosY = object.FindCTrack(desc_y)
                  trackPosZ = object.FindCTrack(desc_z)
                  
                  
                  if trackPosX is None:  
                      track = c4d.CTrack(object, desc_x)
                      object.InsertTrackSorted(track)
                      
                  if trackPosY is None:  
                      track = c4d.CTrack(object, desc_y)
                      object.InsertTrackSorted(track)
                      
                  
                  if trackPosZ is None:
                      track = c4d.CTrack(object, desc_z)
                      object.InsertTrackSorted(track)
                      
              def setPositionKey(object, time, pos):
                  
                  trackPosX = object.FindCTrack(desc_x)
                  trackPosY = object.FindCTrack(desc_y)
                  trackPosZ = object.FindCTrack(desc_z)
                  
                  curvePosX = trackPosX.GetCurve()
                  curvePosY = trackPosY.GetCurve()
                  curvePosZ = trackPosZ.GetCurve()
                  
                  keydict = curvePosX.AddKey(time)
                  key = keydict["key"]
                  key.SetValue(curvePosX,pos.x)
                 
                  keydict = curvePosY.AddKey(time)
                  key = keydict["key"]
                  key.SetValue(curvePosY,pos.y)
                 
                  keydict = curvePosZ.AddKey(time)
                  key = keydict["key"]
                  key.SetValue(curvePosZ,pos.z)
                  
                  return True
                  
              def main():
                  o = op.GetObject()
                  source = o[c4d.ID_USERDATA,1]
                  target = o[c4d.ID_USERDATA,2]
                  offset = o[c4d.ID_USERDATA,3]
                  
                  if source is not None and target is not None:
                      t = doc.GetTime()
                      createPositionTracks(target)
                      setPositionKey(target,t,source.GetAbsPos() + offset)
                      
              
              1 Reply Last reply Reply Quote 0
              • A
                andmotion
                last edited by

                So Did I missed the actual link to my null object?

                1 Reply Last reply Reply Quote 0
                • ferdinandF
                  ferdinand
                  last edited by

                  Hi,

                  woah, a lot of text here 😉 Jeah, op would be a candidate for a node. I can't tell you that, you have to know where you want to get your data from.

                  I am also not quite sure, what your last question means.

                  Cheers
                  zipit

                  MAXON SDK Specialist
                  developers.maxon.net

                  1 Reply Last reply Reply Quote 0
                  • A
                    andmotion
                    last edited by

                    I have my user date applied on to the null plus python tag is also sitting on the null.
                    So I think in def main():
                    I need to get the tag first and then null in order to read the data from userdata......
                    That's make sense for me anyway)
                    Thanks

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by

                      Hello and thanks for the question,

                      Nice you end up by solving your issue, i would like to point you to our example on Github where you will find the same kind of script but with undo system and cloning the whole track, removing the existing one (if it does)

                      For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

                      • Q&A New Functionality.
                      • How to Post Questions especially the tagging part.

                      I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

                      Cheers
                      Manuel.

                      MAXON SDK Specialist

                      MAXON Registered Developer

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        andmotion @Manuel
                        last edited by

                        @m_magalhaes

                        Thanks.

                        Next time I will follow the instruction.
                        Thanks

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