Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 5
thavasi1982
458 Views, 4 Replies

Break

I have many circle over a line. I want to break that line at the crossing of Circles. I have taken the intersections by vla-itersectwith. But i am starting to break, i am not able to identify the object id. STM
4 REPLIES 4
Message 2 of 5
Rtogores
in reply to: thavasi1982

I assume that to split the entity you are using the _BREAK command. This command requires as argument a list similar to that returned by entsel, which includes the entity's ename and the pick point.
As the pick points are obtained from a vlax-curve function they will be expressed as WCS coordinates, but when an AutoCAD command is used these points must be expressed in the current UCS. So it will be necessary to use the trans function, to transform these points to the current UCS, evaluating (trans pt 0 1).
That point is taken as the break's first point, but since that's not what we want, we have to resort to the _First option. As always when using commands we must take care of canceling all running object snap modes, including both 2D and 3D (setvar "3DOSMODE" 1).

For the second point the character "@" returns the last point specified, expressed as UCS coordinates for the current space, value that is stored in the  LASTPOINT system variable.
An important thing to take into account when using this command is that the next entity to break is not the original one, but the last entity created, which can be retrieved by entlast.

And maybe you would have to tweak the order of the breaking points so the next point would be on the newly created line entity. I mean that the points should be ordered in the direction from the line's initial point to its end point. Maybe you could try doing a new LINE entity selection using the new break point`s coordinates instead.

Message 3 of 5
Kent1Cooper
in reply to: thavasi1982


@thavasi1982 wrote:
I have many circle over a line. I want to break that line at the crossing of Circles. I have taken the intersections by vla-itersectwith. But i am starting to break, i am not able to identify the object id. STM

Though the Command:-line version doesn't accept it, when you're inside a Lisp (command) function, you can give Break just an entity name, and it will go into First-point mode without your specifying the F option.  If 'ename' is a Line's entity name, and 'pt' is a point [such as one of your intersections], this will Break that Line at that point:

 

(command "_.break" ename pt pt)

 

If you put all the intersections into one list, you can sort them by their distance from the starting end of the LIne [the 10 entry in its entity data].  Then you can Break the Line repeatedly starting with the intersection that's farthest away, and work closer, and the entity name you give to Break will remain the same all the way down -- the new entity made by each Break command will be the part farther from the starting end of the Line.

 

Another way to do it would be to add the Line endpoints into the list of intersection points, sort them by distance from either end of the Line, then just delete/Erase the original Line and draw a string of new Lines along all those points in sequence.  That could be done with one Erase or (entdel) and one Line command, rather than a whole string of Break commands.  Or it could be done wih (entmake)s instead of (command) function(s) -- one nice feature about that approach is that there would be no need to use (trans) if you might ever be in some non-World Coordinate System when you do it.  And if you're talking about a large number of Lines/Breaks, you might notice the shorter amount of time it would take.

Kent Cooper, AIA
Message 4 of 5
Kent1Cooper
in reply to: thavasi1982


@thavasi1982 wrote:
I have many circle over a line. I want to break that line at the crossing of Circles. I have taken the intersections by vla-itersectwith. But i am starting to break, i am not able to identify the object id. STM

Another possibility would be to use

(vlax-curve-getParamAtPoint line-ename intersection)

or

(vlax-curve-getDistAtPoint line-ename intersection)

with each of the intersections, and put those Parameter values or Distances into a list, because either way will give you just a list of real numbers, which will be much easier to sort into order than sorting intersection points by their distance from the start of the Line.  Then use

(vlax-curve-getPointAtParam line-ename parametervalue)

or

(vlax-curve-getPointAtDist line-ename distancevalue)

through the sorted list for the locations at which to Break the Line [or through which to draw new Lines].

 

[Edit:  Since you will have converted the Line to a VLA object to use (vla-intersectwith) with it, you can use the object instead of the entity name in the above -- (vlax-curve-...) functions will accept either.]

 

How far have you gotten in "taking" the intersections?  Do you have the intersections related to each Circle only as (vla-intersectwith) returns them, as variants?  Or do you have those already extracted via safe-arrays into six-number lists of coordinates related to each Circle?  Or do you have them subdivided into a pair of three-coordinate point lists related to each Circle?  For any of the above possibilities, are those assembled into a collective list?  Or do you have all of the intersections already assembled into one overall list of points?

Kent Cooper, AIA
Message 5 of 5
cab2k
in reply to: thavasi1982

My old routine my be of some help. http://www.theswamp.org/index.php?topic=6245.msg131631#msg131631

 

To get the current version you must be a memeber & use this link.

http://www.theswamp.org/index.php?topic=10370.0

 

 The new version includes:

;;; Version:  2.2  July 28, 2012
;;; Purpose: Break All selected objects
;;;    permitted objects are lines, lwplines, plines, splines,
;;;    ellipse, circles & arcs
;;;                            
;;;  Function  c:MyBreak -       DCL for selecting the routines
;;;  Function  c:BreakAll -      Break all objects selected with each other
;;;  Function  c:BreakwObject  - Break many objects with a single object
;;;  Function  c:BreakObject -   Break a single object with other objects
;;;  Function  c:BreakWith -     Break selected objects with other selected objects
;;;  Function  c:BreakTouching - Break objects touching selected objects
;;;  Function  c:BreakSelected - Break selected objects with any objects that touch it
;;;  Function  c:BreakRemove - Break selected object with any objects that touch it & remove
;;;                         every other new segment, start with selected object
;;;  Revision 1.8 Added Option for Break Gap greater than zero
;;;  NEW r1.9  c:BreakWlayer -   Break objects with objects on a layer
;;;  NEW r1.9  c:BreakWithTouching - Break touching objects with selected objects
;;;  Revision 2.0 Fixed a bug when point to break is at the end of object
;;;  Revision 2.1 Fixed another bug when point to break is at the end of object
;;;  Revision 2.2 Fixed another bug when closed objects are to be broken

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost