Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

constructing infinite lines by selecting lines ?

3 REPLIES 3
Reply
Message 1 of 4
shehab10
458 Views, 3 Replies

constructing infinite lines by selecting lines ?

Hi, Is there way that by selecting objects (Lines,Pl) it construct infinite lines ?

 

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: shehab10


@shehab10 wrote:

Hi, Is there way that by selecting objects (Lines,Pl) it construct infinite lines ?

 


You can use Bisector.lsp and its BI command, which you can download here.  It's designed to draw an Xline bisecting the angle between any two straight entities, or bisecting the spacing between them if they're parallel, but if you pick on the same Line or Polyline line segment twice, it will draw an Xline over it, extending [as Xlines do] infinitely in both directions.

 

EDIT:  That's assuming that what you want to do with a Polyline is to make an Xline overlaying one line segment thereof.  If you intend something different [e.g. an Xline through its endpoints even if it has more than one segment, or through the adjacent vertices even if it's picked on an arc segment], it would need to be done differently.

Kent Cooper, AIA
Message 3 of 4
Kent1Cooper
in reply to: shehab10

That could, of course, be altered to require only selection, rather than needing to pick on something twice.  And subsequently, various questions occur to me:

 

Would you want to select multiple Lines collectively, and have this done to all of them at once, rather than only one at a time?  In simplest terms, without any of the usual controls yet, something like this will do that [on Lines only]:

 

(defun C:L2XL (); = Line To XLine
  (prompt "\nSelect Line(s) on which to overlay Xline(s): ")
  (if
    (setq ss (ssget '((0 . "LINE"))))
    (repeat (sslength ss)
      (setq ldata (entget (ssname ss 0)))
      (command "_.xline" "_none" (cdr (assoc 10 ldata)) "_none" (cdr (assoc 11 ldata)) "")
      (ssdel (ssname ss 0) ss)
    ); repeat
  ); if
  (princ)
); defun

 

Would you want the selected Lines to be erased in the process?

 

Would you want the Xlines on the same Layer(s) as the selected Lines, or on the current Layer, whatever it is, or on some defined layout Layer?

 

Is the mention of Polylines for the case of those that are of a single line segment and therefore equivalent to Lines?  If multiple-segment, would you want Xlines laid over the segment on which each was selected, eliminating the option of selecting more than one with Window/Crossing/Fence/WP selection options?

 

Etc.....

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

By using entmake[x], it becomes easier to match existing object properties, e.g.:

 

(defun c:lxl ( / e i s )
    (if (setq s (ssget '((0 . "LINE"))))
        (repeat (setq i (sslength s))
            (setq e (entget (ssname s (setq i (1- i)))))
            (entmake
                (append
                    (list
                       '(000 . "XLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbXline")
                        (assoc 10 e)
                        (cons  11 (mapcar '- (cdr (assoc 11 e)) (cdr (assoc 10 e))))
                    )
                    (LM:defaultprops e)
                )
            )
        )
    )
    (princ)
)

;; Default Properties  -  Lee Mac
;; Returns a list of DXF properties for the supplied DXF data,
;; substituting default values for absent DXF groups
 
(defun LM:defaultprops ( elist )
    (mapcar
        (function
            (lambda ( pair )
                (cond ((assoc (car pair) elist)) ( pair ))
            )
        )
       '(
            (008 . "0")
            (006 . "BYLAYER")
            (039 . 0.0)
            (062 . 256)
            (048 . 1.0)
            (370 . -1)
        )
    )
)

(princ)

 


Kent1Cooper wrote: 

 

    (repeat (sslength ss)
      (setq ldata (entget (ssname ss 0)))
      (command "_.xline" "_none" (cdr (assoc 10 ldata)) "_none" (cdr (assoc 11 ldata)) "")
      (ssdel (ssname ss 0) ss)


I realise this is only a quick example, but in general, I would strongly advise against this method of selection set iteration, since as described in my tutorial here, every time an entity is removed from position 0 in the selection set array, the remaining items in the set are all needlessly shifted to a lower index, which is highly inefficient.

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

Post to forums  

Autodesk Design & Make Report

”Boost