Scripting rail styles

When using the graphical interface, it is possible to select styles for rail in Sweep1 (for instance “Roadlike Top”)
In RhinoScript, rs.AddSweep1() does not allow that style option.
I tried to add it, but without success.
Any hint about how to implement that style option successfully ?
Thanks !

@cyl,

it seems the rs.AddSweep1 method is not complete. As a workaround you can use RhinoCommon, here is the example script from the docs:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext

def Sweep1():
    rail = rs.GetObject("Select rail curve", rs.filter.curve)
    rail_crv = rs.coercecurve(rail)
    if not rail_crv: return
    
    cross_sections = rs.GetObjects("Select cross sections", rs.filter.curve)
    if not cross_sections: return
    cross_sections = [rs.coercecurve(crv) for crv in cross_sections]
    
    sweep = Rhino.Geometry.SweepOneRail()
    sweep.AngleToleranceRadians = scriptcontext.doc.ModelAngleToleranceRadians
    sweep.ClosedSweep = False
    sweep.SweepTolerance = scriptcontext.doc.ModelAbsoluteTolerance
    sweep.SetToRoadlikeTop()
    breps = sweep.PerformSweep(rail_crv, cross_sections)
    for brep in breps: scriptcontext.doc.Objects.AddBrep(brep)
    scriptcontext.doc.Views.Redraw()
    
if __name__ == "__main__":
    Sweep1()

c.

1 Like

@clement
Many thanks for your help !
Not only it works nicely, but this is for me a good example of RhinoCommon use.