I have a rail curve and some shape curves.

when I using sweep1 command I can get a brep jus as my required.

when I using Rhino1RailSweep fuction I also can get a brep,but this brep is not my required.

when I using RhinoSweep1 funtion I can’t get any breps.

next is my whole codes,I want upload the 3dm file and codes as a attachment.

but I don’t konw how to upload a attachmen

```
//获取形状线端点在路径线上的参数值
bool GetShapeParameterOnRail( const ON_Curve& shape, const ON_Curve& rail, double tol, double& t )
{
ON_Interval rail_domain = rail.Domain();
double dis1=100000;
double t1;
double dis2=100000;
double t2;
//测试开始点;
bool rc = rail.GetClosestPoint( shape.PointAtStart(), &t1, tol );//得到起点;
if( rc )
{
if( rail.IsClosed() )
{
if( fabs(t - rail_domain.Max()) < ON_SQRT_EPSILON )
t1 = rail_domain.Min();
if( fabs(t - rail_domain.Min()) < ON_SQRT_EPSILON )
t1 = rail_domain.Min();
}
ON_3dPoint point1=rail.PointAt(t1);
dis1=point1.DistanceTo(shape.PointAtStart());
}
// 测试端点;
rc = rail.GetClosestPoint( shape.PointAtEnd(), &t2, tol );
if( rc )
{
if( rail.IsClosed() )
{
if( fabs(t2 - rail_domain.Max()) < ON_SQRT_EPSILON )
t2 = rail_domain.Min();
if( fabs(t2 - rail_domain.Min()) < ON_SQRT_EPSILON )
t2 = rail_domain.Min();
}
ON_3dPoint point2=rail.PointAt(t2);
dis2=point2.DistanceTo(shape.PointAtEnd());
}
if(rc)//说明起点和终点有一个是在路径线上，取最近的那个点
{
if(dis1<dis2)
{
t=t1;
}
else
{
t=t2;
}
return true;
}
// 尝试相交
ON_SimpleArray<ON_X_EVENT> x;
if( 1 == rail.IntersectCurve(&shape, x, tol, 0.0) && x[0].IsPointEvent() )
{
t = x[0].m_a[0];
if( rail.IsClosed() )
{
if( fabs(t - rail_domain.Max()) < ON_SQRT_EPSILON )
t = rail_domain.Min();
}
return true;
}
return false;
}
bool Sweep1(ON_Curve* in_rail,ON_SimpleArray<const ON_Curve*>in_secs,ON_SimpleArray<ON_Brep*>& out_breps)
{
CArgsRhinoSweep1 args;
CRhinoPolyEdge edge_copy;
edge_copy.Create(in_rail);
args.m_rail_curve =&edge_copy;
args.m_bHaveRailPickPoint = false;
args.m_bUsePivotPoint = false;
double tol= RhinoApp().ActiveDoc()->AbsoluteTolerance();
for( int i = 0; i < in_secs.Count(); i++ )
{
double t = 0;
if( !GetShapeParameterOnRail(*in_secs[i], edge_copy, 0.2, t) )
return 0;
args.m_shape_curves.Append( const_cast<ON_Curve*>(in_secs[i]));
args.m_rail_params.Append( t );
}
args.m_bUsePoints[0] = 0;
args.m_bUsePoints[1] = 0;
args.m_bClosed = true;
args.m_style = 0;
args.m_planar_up = ON_zaxis; // Don't need this, but set it anyway..
args.m_simplify = 0; // Simplify method for shape curves
args.m_rebuild_count = -1; // Sample point count for rebuilding shapes
args.m_refit_tolerance = 0.01;
args.m_sweep_tolerance =0.01;
args.m_angle_tolerance =0.01;// RhinoApp().ActiveDoc()->AngleToleranceRadians();
RhinoSweep1(args, out_breps);
return (out_breps.Count()>=1) ? true : false;
}
CRhinoCommand::result CCommandHide::RunCommand( const CRhinoCommandContext& context )
{
CRhinoGetObject go;
go.SetCommandPrompt( L"Select rail curve" );
go.SetGeometryFilter( CRhinoGetObject::curve_object );
go.GetObjects(1,1);
if( go.CommandResult() != success )
return go.CommandResult();
const CRhinoObjRef& rail_ref = go.Object(0);
const CRhinoObject* rail_obj = rail_ref.Object();
if( !rail_obj )
return failure;
const ON_Curve* rail_crv = rail_ref.Curve();
if( !rail_crv )
return failure;
CRhinoGetObject gx;
gx.SetCommandPrompt( L"Select cross section curves" );
gx.SetGeometryFilter( CRhinoGetObject::curve_object );
gx.EnablePreSelect( false );
gx.EnableDeselectAllBeforePostSelect( false );
gx.GetObjects(1,0);
if( gx.CommandResult() != success )
return gx.CommandResult();
ON_Curve* rail=rail_crv->DuplicateCurve();
ON_SimpleArray<const ON_Curve*>shapes;
int i;
for( i = 0; i < gx.ObjectCount(); i++ )
{
const CRhinoObjRef& obj_ref = gx.Object(i);
const ON_Curve* crv = obj_ref.Curve();
if( crv )
{
ON_Curve* dup_crv = crv->DuplicateCurve();
shapes.Append(dup_crv);
}
}
ON_SimpleArray<ON_Brep*> breps;
#if 0
Sweep1(rail,shapes,breps);
#else
Rhino1RailSweep(breps,rail,shapes,true);
#endif
for( i = 0; i < breps.Count(); i++ )
{
context.m_doc.AddBrepObject( *breps[i] );
delete breps[i];
}
delete rail;
for( i = 0; i < shapes.Count(); i++ )
delete shapes[i];
context.m_doc.Redraw();
return success;
}
```