.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Break At Point

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
1736 Views, 15 Replies

Break At Point

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

 

15 REPLIES 15
Message 2 of 16
SENL1362
in reply to: Anonymous

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.

 

 

Message 3 of 16
Anonymous
in reply to: SENL1362

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

Message 4 of 16
SENL1362
in reply to: Anonymous

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;
        }

 

Message 5 of 16
Anonymous
in reply to: SENL1362

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

Message 6 of 16
SENL1362
in reply to: Anonymous

I'll bet you're off in the 26e decimal 🙂
Last week i had similar experience when searching for the right corner of a polyline.
Try using the curve.GetClosestPoint(), and then Split the curve.
Message 7 of 16
Anonymous
in reply to: SENL1362

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?

Message 8 of 16
SENL1362
in reply to: Anonymous

I don't see any errors in code so it must be in the data. Is the SplitPoint one of the endponts of the line?

Message 9 of 16
Anonymous
in reply to: SENL1362

Its not endpoint of a line...

 

Is there any other way other than this..?

Message 10 of 16
Anonymous
in reply to: SENL1362

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

Message 11 of 16
_gile
in reply to: Anonymous

Hi,

 

Send the command inputs in the right order:

ed.Command("_.BREAK", line1, "_first", point3d1, "@");

 Note that point3d1 have to be expressed in current UCS coordinates.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 12 of 16
Anonymous
in reply to: _gile

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."

Message 13 of 16
_gile
in reply to: Anonymous


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, "@");

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 14 of 16
Anonymous
in reply to: _gile

Hi Gilles,

 

Still facing the same error.

 

I checked the Co-ordinates also, its expressed in the WCS.

 

Message 15 of 16
_gile
in reply to: Anonymous

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.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 16 of 16
Anonymous
in reply to: _gile

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.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report