Insert 2 point spline



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

    On 05/07/2011 at 00:03, xxxxxxxx wrote:

    Anyone got the code to insert a basic spline with 2 points into a scene

    Started to look up spline in the docs and its a tad daunting

    tia



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

    On 05/07/2011 at 04:45, xxxxxxxx wrote:

    # written on mobile device, not tested yet  
    import c4d  
      
    def main() :  
    # get the first 2 objects in the scene  
    o1 = doc.GetFirstObject()  
    o2 = o1.GetNext()  
      
    o1 = o1.GetAbsPos(); o2 = o2.GetAbsPos()  
      
    spl = c4d.BaseObject(c4d.Ospline)  
    spl.ResizeObject(2) # pointcount  
      
    spl.SetPoint(0, o1)  
    spl.SetPoint(1, o2)  
    spl.Message(c4d.MSG_POINTS_CHANGED) # tell the spline it's points did change  
      
    doc.InsertObject(spl)  
      
    c4d.EventAdd()  
      
    return True  
      
    if __name__ == "__main__":  
    main()
    

    Cheers,
    Niklas



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

    On 05/07/2011 at 05:07, xxxxxxxx wrote:

    Hi Niklas

    Many thanks - a great helper

    This is the sort of example we need in the documentation



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

    On 05/07/2011 at 08:40, xxxxxxxx wrote:

    Here's an example using the spline class:

    import c4d  
    from c4d import gui  
      
    def main() :  
      myspline = c4d.SplineObject(2,c4d.SPLINETYPE_BEZIER)  #Create a 2pt. Bezier spline in memory only  
      p1 = myspline.GetSplinePoint(0)  #Assign the first point to a variable                  
      p2 = myspline.GetSplinePoint(1)  #Assign the second point to a variable   
      
      myspline.SetPoint(0, c4d.Vector(-100,0,0)) #Place the first point here  
      myspline.SetPoint(1, c4d.Vector(100,0,0))  #Place the second point here  
      myspline.Message(c4d.MSG_UPDATE)  #Should do this any time an object's points are changed     
       
      doc.InsertObject(myspline)  #Insert it into the Object Manager from memory  
      c4d.EventAdd() #Update C4D about the changes  
      
    if __name__=='__main__':  
      main()
    

    From here.
    You can use the SplineData, SplineHelper, SplineLengthData classes on it to manipulate the points, segments, tangents.

    -ScottA



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

    On 05/07/2011 at 09:11, xxxxxxxx wrote:

    As oyu might have notices, I already have posted a solution. ;)



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

    On 05/07/2011 at 10:15, xxxxxxxx wrote:

    Yeah. But he was asking how to make a two point spline based on the documentation.
    And you posted an example using a spline object with it's points in the same positions as two objects.

    He won't learn how to use the docs from that.
    So I just thought that I'd give him an example that is based closer to how it's done in the docs.
    That way he can see how they work. And be able to use the other functions and classes.

    -ScottA



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

    On 05/07/2011 at 15:18, xxxxxxxx wrote:

    Its ok guys, you both helped out tremendously!



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

    On 05/07/2011 at 22:52, xxxxxxxx wrote:

    Thanks for ALL the input.

    Be it short, long, official or whatever. Its actually very useful to see there's more than one way tackle the problem.


Log in to reply