Hi,


I want to create surface that has 5 control points in U direction.But the result always only has 4 control points. Can you help me to find the Bug?

 

Thanks,

Simon

 

Here is my code:


  List<Brep> breps=Sweep2(rail_crv1,rail_crv2,shape_curves,5);
 foreach (Brep Item in breps)
            {
                doc.Objects.AddBrep(Item );
            }

==============================

 public List<Brep> Sweep2(Curve Rail1, Curve Rail2,List<Curve> shape_curves , int m_rebuild_count  )
        {
            if (!Rhino.Geometry.Curve.DoDirectionsMatch(Rail1, Rail2))
                Rail2.Reverse();

            Rhino.Geometry.SweepTwoRail sweep = new Rhino.Geometry.SweepTwoRail();
            RhinoDoc doc = RhinoDoc.ActiveDoc;

            sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians;
            sweep.ClosedSweep = Rail1.IsClosed & Rail2.IsClosed ;
            sweep.SweepTolerance = doc.ModelAbsoluteTolerance;
            sweep.MaintainHeight = true;
            var breps=sweep.PerformSweepRebuild(Rail1, Rail2, shape_curves, m_rebuild_count);
            return new List<Brep>(breps);
     

        }

 

Views: 147

Replies to This Discussion

Hi Simon,

If you use Rhino's Sweep2 command, can you rebuild the shape with 4 control points?

Can you post the geometry?

Thanks,

 -- Dale

Hi Dale,

 

Rhino's Sweep2 command works well.

The test code as below,Please help to check.

 

Thanks,

Simon

 

private List<Brep> Sweep2(Curve Rail1, Curve Rail2, List<Curve> shape_curves, int m_rebuild_count)
        {
           // if (!Rhino.Geometry.Curve.DoDirectionsMatch(Rail1, Rail2))
            //    Rail2.Reverse();
            Rhino.Geometry.SweepTwoRail sweep = new Rhino.Geometry.SweepTwoRail();
            RhinoDoc doc = RhinoDoc.ActiveDoc;

            sweep.AngleToleranceRadians = doc.ModelAngleToleranceRadians;
            sweep.ClosedSweep = Rail1.IsClosed & Rail2.IsClosed;
            sweep.SweepTolerance = doc.ModelAbsoluteTolerance;
            sweep.MaintainHeight = true;
            var breps = sweep.PerformSweepRebuild(Rail1, Rail2, shape_curves, m_rebuild_count);
            return  new List<Brep>(breps);
        }

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            doc.Objects.UnselectAll();
            Rhino.DocObjects.ObjRef rail1_ref;
            var rc = RhinoGet.GetOneObject("Select rail curve1", false, Rhino.DocObjects.ObjectType.Curve, out rail1_ref);
            if (rc != Rhino.Commands.Result.Success)
                return rc;

            var rail1_crv = rail1_ref.Curve();
            if (rail1_crv == null)
                return Rhino.Commands.Result.Failure;
            doc.Objects.UnselectAll();
            Rhino.DocObjects.ObjRef rail2_ref;
             rc = RhinoGet.GetOneObject("Select rail curve2", false, Rhino.DocObjects.ObjectType.Curve, out rail2_ref);
            if (rc != Rhino.Commands.Result.Success)
                return rc;

            var rail2_crv = rail2_ref.Curve();
            if (rail2_crv == null)
                return Rhino.Commands.Result.Failure;

            if (!Rhino.Geometry.Curve.DoDirectionsMatch(rail1_crv, rail2_crv))
                rail2_crv.Reverse();

            Line line1 = new Line(rail1_crv.PointAtStart, rail2_crv.PointAtStart  );
            Line line2 = new Line(rail1_crv.PointAtEnd, rail2_crv.PointAtEnd );

            List<Curve> sectionLine  =new List<Curve> ();
            sectionLine.Add(line1.ToNurbsCurve());
            sectionLine.Add(line2.ToNurbsCurve());

            List<Brep> breps=Sweep2(rail1_crv, rail2_crv, sectionLine, 5);
            foreach (Brep brep in breps)
            {
                doc.Objects.AddBrep(brep);
            }

          
            doc.Views.Redraw();
           
            return Result.Success;
        }

Attachments:

Hi Simon,

Thank you for posting your geometry. With it, I was able to track down a bug in Rhino that was causing the shape curves to not rebuild. I have fixed the problem in Rhino. But it is too late for the fix to make it into Rhino 5 SR2. So, look for the fix when Rhino 5 SR3 is available.

Thanks again.

 -- Dale

Hi Dale,

 

I'm looking forward to the Rhino 5 SR3 can release earlier.

Is there any other way to replace PerformSweepRebuild function in RhinoCommon?

 

Thanks,

Simon

 

Hi Dale,

 

If no way to replace PerformSweepRebuild function,can you tell me how to get the count of control point in U direction? 

 

Thanks,

Simon

SweepOneRail.PerformSweepRebuild returns an array of Breps. You'd have to:

1. Get a Brep from the results
2. Get a BrepFace from the Brep.
3. Get the face's underlying surface.
4. Make sure the surface is a NURBS surface.
5. Get the NURBS surface's point count in the U direction.

Let me know if you need an example.

 -- Dale

The only work around, until SR3, is to script the Sweep1 command using Rhino.RhinoApp.RunScript.

 -- Dale

RSS

Translate

© 2014   Created by McNeel Admin.

Badges  |  Report an Issue  |  Terms of Service