extrude curve along curve script example?

  • amj

    amj - 2015-04-12


    I am new to groovy scripting. I am trying to make a surface by defining two curves and then extruding one curve along the other. I originally thought I could script the two curves and manually do the extrusion, but the objects are scripted objects, not curves as I thought the script would originally produce. I am having difficulties parsing through the ExtrudeTool and the corresponding ExtrudeDialog. If anyone can provide some example code where one curve is extruded along another in a script that would be most helpful.

    Thank you,

  • amj

    amj - 2015-04-12

    Okay, I was able to figure out how to extrude one curve along another. I am certain there is a much better way to get this egg-crate shape, but in case you are interested here is my code:

    total_points = 200
    curve_points = new Vec3[total_points]
    // Extra curve arguments
    float[] smoothness = new float[total_points]
    int smoothing_method = 0
    is_closed = false
    // Define the profile sine squared curve
    wavevector = 0.109955  // fits an integer number of half wavelengths
    amplitude = 20
    for (kk=0; kk < total_points; kk++){
        y = amplitude * ( Math.sin(wavevector * kk) )**2
        z = 0
        def point = new Vec3(kk, y, z)
        curve_points[kk] =  point
        smoothness[kk] = 0
    cosine_squared = new Curve(curve_points, smoothness, smoothing_method, is_closed)
    script.addObject(cosine_squared, new CoordinateSystem())
    // Define the path sine squared curve to extrude first along.
    // The orientation will be 90 degrees with respect to the first curve.
    extrude_curve_points = new Vec3[total_points]
    for (kk=0; kk < total_points; kk++){
       x = 0
       y = amplitude * ( Math.sin(wavevector * kk) )**2
       z = kk
       def point = new Vec3(x, y, z)
       extrude_curve_points[kk] = point
    extrude_line = new Curve(extrude_curve_points, smoothness, smoothing_method, is_closed)
    script.addObject(extrude_line, new CoordinateSystem())
    // Extrude object
    extrude_tool = new tools.ExtrudeTool()
    extruded_surface = extrude_tool.extrudeCurve(cosine_squared, extrude_line, new CoordinateSystem(), new CoordinateSystem(), 0, false)
    script.addObject(extruded_surface, new CoordinateSystem())
  • Peter Eastman

    Peter Eastman - 2015-04-12

    You don't need to call script.addObject() for the two curves, unless you actually want them to show up in the UI. You can create whatever objects you want in the process of creating your final extruded surface. Only call addObject() for ones that you want to show up as part of your "final result".

    Also, extrudeCurve() is a static method, so you don't need to create an ExtrudeTool object. Just call

    extruded_surface = tools.ExtrudeTool.extrudeCurve(...)



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks