Questions about the Delete method

  1. Import several lines from the dwg file, this time may be PolyCurve or PolylineCurve
  2. Break these straight lines into pure straight lines
  3. Based on the data of these lines, create a new LineCurve and add it to Rhino
  4. Delete lines imported from dwg file

expected results
New LineCurves created are not affected

actual results
All lines are removed

     public void Import(string fileName)
        {
            RhinoApp.InvokeAndWait(new Action(() =>
            {
                RhinoApp.RunScript(@"-Import ""\\192.168.50.103\Louge\CAD\" + fileName + @""" Enter", true);
                RhinoDoc.ActiveDoc.Views.Redraw();
            }));
        }

                Import("轴线.dwg");
    var rhinoObjects = RhinoDoc.ActiveDoc.Objects;
            var geometries = rhinoObjects.Select(x => x.Geometry).ToArray();
            GetLineObject getLineObject = new GetLineObject();
            getLineObject.Lines = geometries.OfType<LineCurve>()
                .Select(x => x.Line)
                .ToList();
            if (!getLineObject.Lines.Any())
            {
                throw new Exception("没有轴线,必须要有轴线");
            }

            foreach (var line in getLineObject.Lines)
            {
                RhinoDoc.ActiveDoc.Objects.Add(new LineCurve(line.From, line.To));
            }
            foreach (var item in rhinoObjects)
            {
                RhinoDoc.ActiveDoc.Objects.Delete(item);
            }

Hi @ken_zhang,

Here is a sample command that converts polylines into line segments.

TestKenZhang.cs (1.4 KB)

Does this help?

– Dale