Hi,
I want to use the Break At Point using .Net. I have a Line -> Arc -> Line. I have used a fillet command with radius zero to extend the line meeting point. Now i need to break the extended line at the intersection of the both ends of the Arc.
How can use Break at point. I have attached image, this might help in understanding
Have a look at curve.GetSplitCurves(...)
You can split the curve using more than one breakpoint at once but this might return the wrong parts.
to get started use it like this:
Curve tmpCurve= TheLine as Curve; Point3dCollection tmpSplitPnt = new Point3dCollection(new Point3d[] { splitPnt_1 }); DBObjectCollection tmpSplittedCurves = tmpCurve.GetSplitCurves(tmpSplitPnt); ...
Also note that you can split lines, polylines, arcs but not Circle using GetSplitCurves.
Hi,
I am getting an error when using the suggested method.
An exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll but was not handled in user code
Additional information: eInvalidInput
The SplitPoint must be on the line. Did you check that?
Use Google to search for some articles describing the usage.
public static bool IsPointOnCurveGCP(Curve cv, Point3d pt) { try { Point3d p = cv.GetClosestPointTo(pt, false); return (p - pt).Length <= Tolerance.Global.EqualPoint; } catch { } return false; }
Hi,
Yes i am actually checking if the point lies on a line using the below formula
" if (x - x1) / (x2 - x1) = (y - y1) / (y2 - y1) = (z - z1) / (z2 - z1) then point lies on the line ".
But still i get that error
Hi,
Below is my code
DBObject obj = acTrans.GetObject(lineent.objId, OpenMode.ForRead);
Line ln = obj as Line;
Curve tmpCurve = ln as Curve;
if (checkifPointLiesOnLine(lineentity, orphanPoint3D))
{
Autodesk.AutoCAD.Geometry.Point3dCollection tmpSplitPnt = new Autodesk.AutoCAD.Geometry.Point3dCollection(new Autodesk.AutoCAD.Geometry.Point3d[] { orphanPoint3D });
DBObjectCollection tmpSplittedCurves = tmpCurve.GetSplitCurves(tmpSplitPnt);
}
It lies on the line and i have using a decimal places upto 5.
I tried even the method suggested you. Still the same error.
Autodesk.AutoCAD.Geometry.Point3dCollection tmpSplitPnt = new Autodesk.AutoCAD.Geometry.Point3dCollection(new Autodesk.AutoCAD.Geometry.Point3d[] { tmpCurve.GetClosestPointTo(orphanPoint3D , true) });
DBObjectCollection tmpSplittedCurves = tmpCurve.GetSplitCurves(tmpSplitPnt);
Any Idea?
Hi,
I am trying to use the ed.command() to execute.
ed.Command("_.break", "f ", line1, point3d1, point3d1);
Do you how to use this ?
I have also attached a sample. The GREEN lines has to be split at the joining poiints of RED Arc
Hi Gilles,
I am getting the below error.
An exception of type 'System.ArgumentException' occurred in AcdbMgd.dll but was not handled in user code
Additional information: Value does not fall within the expected range.
And What do you mean by "point3d1 have to be expressed in current UCS coordinates."
santoshr0114 a écrit :
And What do you mean by "point3d1 have to be expressed in current UCS coordinates."
Extract from this page in the AutoCAD .NET developer's Guide:
"All points passed in and out of the methods and properties in the .NET API are expressed in the WCS unless otherwise specified."
The main exception to this sentence is for points passed in and out of the Editor: PromptPointResult.Value is expressed in the current UCS and the points passed to Editor.Command(), Document.SendStringToExecute() and AcadDocument.SendCommand() have to be expressed in the current UCS too.
For example, if you didn't get point3d1 from ed.GetPoint() but from someCurve.EndPoint or someCurve.StartPoint, for example, point3d1 will be expressed in WCS and you'll have to tranform it before passing it to ed.Command() method.
The Editor.CurrentCoordinateSystem property return the transformation matrix to be used to transform coordinates fron UCS to WCS, you get the inverse transformation matrix with the Matrix3d.Inverse() method.
So if point3d1 is expressed in WCS, you can do it this way:
ucsPoint3d1 = point3d1.TransformBy(ed.CurrentCoordinateSystem.Inverse()); ed.Command("_.BREAK", line1, "_first", ucsPoint3d1, "@");
I cannot say anything about the error you get.
If this exception is thrown by this line:
ed.Command("_.BREAK", line1, "_first", point3d1, "@");
you only have to check the line1 and point3d1 arguments.
- line1 have to be the objectId of non erased curve.
- point3d1 have to be a valid Point3d (or Point2d) expressed in current UCS coordinates and which lies on the curve.
Hi Gilles,
The error is resolved. The error was because of the co-odinates. Now its working fine.
My Current Approach
1. User Selects the Entites (Wich are connected)
2. My program validates the connected entites store them in a list.
3. Then loop through the list and see if the line is followed with another line and an arc.
4. If yes the use the Arc start point or end point lying on the line and break at that point.
This works fine, for the first instance.
My question is "does the entity object changes when any transaction commited (After breaking the first instance of the line)"?
Can't find what you're looking for? Ask the community or share your knowledge.