2.34 curve creation bug?

Does anyone know how to use the new append() and appendNurb() methods. I get them to work fine for creating nurbs curves (variables are a list of 4 floats). But when I try to add a “nurb” to a Curve object Blender crashes (I’m on OS X 10.3) with no console message. As you can see below I’ve tried several ways to input the 9 floats (Triplet) which is all the API says. Here’s my code…what am I doing wrong?

from Blender import Curve, Object, Scene, Window 

branch = Curve.New() 

curScene = Scene.getCurrent() 
branchObj = Object.New('Curve') 
branchObj.link(branch) 
curScene.link(branchObj) 

#branch.appendNurb([0,0,5,100])         #works 
#branch[0].append([0,0,2,100])         #works 
#branch[0].append([0,2,2,100])         #works 
#branch[0].append([0,2,2,100])         #works 

branch.appendNurb(0,0,0,0,0,5,0,0,0)      #crashes 
#branch.appendNurb([0,0,0,0,0,5,0,0,0])      #crashes 
#branch.appendNurb([[0,0,0],[0,0,0],[0,0,0]])   #crashes 

branch.update() 
Window.Redraw()

thanks in advance for your help!

…what am I doing wrong?

Don’t think you’re doing anything wrong - I was able to recreate the crash. I had a quick look at the C code for the Python API and I think the code for appendNurb() is not yet complete. Unfortunately, the C function doesn’t call the python error handler to properly print a message, which is why you get a crash… I’ll write a bug report for the developers.

Doesn’t help you much, but at least explains it for now :slight_smile:

[email protected]

P.S. The way I understand the documentation, if you call appendNurb()with triplets you’re not really creating a Nurb but a Bezier curve.

thanks for submitting the bug report…hopefully it’ll be fixed in 2.35! :slight_smile: I did realize that adding a Triplet will create a bezier curve…that’s what I wanted to do…sorry that wasn’t clear from my question.

Does anyone know how to use the new append() and appendNurb() methods. … As you can see below I’ve tried several ways to input the 9 floats (Triplet) which is all the API says

A couple of points ( no pun intended):

  1. You need to look at the API doc for the functions you are calling. It says either a sequence of four floats for a Nurb curve or a BezTriple for a Bezier curve.

  2. The *append() code is unfinished. The code to create a BezTriple is not yet commited. Right now, the only way to get one is to copy it from another Curve using an iterator or the [] operator.

  3. No, it should not crash. The error handling needs work.

thanks for your detailed reply stiv. I was very confused by the bezTriple idea because as you pointed out, there’s no way to create one. The only thing coming close is the getTriple() function in the ipo module. This returns a nested list [ [H1x, H1y, H1z], [Px, Py, Pz], [H2x, H2y, H2z] ]. Which is why I tried passing the same thing into the appendNurb() function.

Do you have any idea when the curve API will be more complete? I submitted a request to the functionality board, but I was hoping it would be available in the 2.35.

Thanks for your help!

The new BezTriple factory and finished append methods will be in the upcoming 2.35.

Because it has been worked on by different people at different times, one thing the BPy API sometimes suffers from is a lack of interoperability between types and methods. The BezTriple type is one step towards smoothing things over. Same for the CurNurb type which, along with its buddy SurfNurb, is part of the planned Curve/Surface build-out.