Jump to content

Recommended Posts

Posted

Hi friends, I need a help with polyline extend and Im not that good at lisp programming

 

I need to extend polylines that have three vertices, but I only want to extend one end of each polyline. The reference for the extension will be another line or polyline that I select, which is longer on one end. Essentially, I want to align the endpoint of my selected polyline with the endpoint of the longer reference line. How can I do this?.

 

Thanks in advance my friends...😃

 

 676034C5-9A4E-44D7-BF70-526CDFE25453.png.a99a0b2729bb6b73f1852f160b71a42e.png

Posted (edited)

Hi @harimaddddy

 

Try this:

 

(prompt "\nTo run a LISP type: EXTLPL")

(defun c:EXTLPL ( / temperr old_echo old_osm e pt obj spt ept dist old_nomutt ss elast len i)
  (setq temperr *error*)
  (setq *error* trap)
  (setq old_echo (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (setq old_osm (getvar 'osmode))
  (setvar 'osmode 512)
  (setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
  (while (or (= e nil) (not (or (= "LINE" (cdr (assoc 0 (entget (car e))))) (= "LWPOLYLINE" (cdr (assoc 0 (entget (car e))))))))
    (if (= e nil)
      (progn
	(prompt "\nNothing was selected. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      (progn
	(prompt "\nSelected entity must be LINE or POLYLINE. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      )
    )
  (cond
    ((= "LINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setq old_nomutt (getvar 'nomutt))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (cadr ept) (cadr spt))
       (progn
	 (command "._xline" "h" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    ((= "LWPOLYLINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setq dist (/ (vlax-get-property obj 'Length) 2))
     (setq old_nomutt (getvar 'nomutt))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (vlax-curve-getDistAtPoint obj pt) dist)
       (progn
	 (command "._xline" "h" spt "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    )
  (entdel elast)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (setq *error* temperr)
  (prompt "\nThe desired LINES or POLYLINES were extended!")
  (princ)
  )

;; Error trap

(defun trap (errmsg)
  (if (not (member errmsg '("console break" "Function Cancelled"))
	   )
    (princ (strcat "\nError: " errmsg ". Resetting Enviroment!"))
    )
  (setq i 0 ss nil len nil)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (terpri)
  (setq *error* temperr)
  (princ)
  )

 

Edited by Saxlle
Add a COND when LINE are base for extending
Posted (edited)

@Saxlle Thanks brother, right now I don't have PC, once reach home I'll update.

Edited by harimaddddy
Posted
24 minutes ago, harimaddddy said:

@Saxlle Thanks brother, right now I don't have PC, once reach home I'll update.

You're welcome

Little advice/notice: it works only for 3 vertices if polyline is and i'm not tested very well.

 

Best regards.

Posted

Hey @Saxlle , it works great! Thanks a lot for your help. I noticed that it’s extending the polylines that are facing to the right, but it doesn’t seem to be working for the ones that are directed to the left (snap-1). Can you help me with that?

 

And, if I use the undo command a couple of times, will that affect any of the AutoCAD variables? Please suggest me to solve the issue brother.

 

snap-1

3A0CDFC3-9A0A-4E8F-BB76-798159B8C7DE.png.d5527586ee97a73ec0185abeff8c2039.png 

 

(prompt "\nTo run a LISP type: EXTLPL")

(defun c:EXTLPL ( / temperr old_echo old_osm e pt obj spt ept dist old_nomutt ss elast len i)
  (setq temperr *error*)
  (setq *error* trap)
  (setq old_echo (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (setq old_osm (getvar 'osmode))
  (setvar 'osmode 512)
  (setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
  (while (or (= e nil) (not (or (= "LINE" (cdr (assoc 0 (entget (car e))))) (= "LWPOLYLINE" (cdr (assoc 0 (entget (car e))))))))
    (if (= e nil)
      (progn
	(prompt "\nNothing was selected. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      (progn
	(prompt "\nSelected entity must be LINE or POLYLINE. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      )
    )
  (cond
    ((= "LINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setq old_nomutt (getvar 'nomutt))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (cadr ept) (cadr spt))
       (progn
	 (command "._xline" "h" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    ((= "LWPOLYLINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setq dist (/ (vlax-get-property obj 'Length) 2))
     (setq old_nomutt (getvar 'nomutt))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (vlax-curve-getDistAtPoint obj pt) dist)
       (progn
	 (command "._xline" "h" spt "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    )
  (entdel elast)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (setq *error* temperr)
  (prompt "\nThe desired LINES or POLYLINES were extended!")
  (princ)
  )

;; Error trap

(defun trap (errmsg)
  (if (not (member errmsg '("console break" "Function Cancelled"))
	   )
    (princ (strcat "\nError: " errmsg ". Resetting Enviroment!"))
    )
  (setq i 0 ss nil len nil)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (terpri)
  (setq *error* temperr)
  (princ)
  )

 

Posted

You're welcome.

I have attached an example video, it depends on which "direction" the polylines are drawn in, the best way is to use the "REVERSE" command, select all polylines and it will work great.

Also, I made a small update to the code, added a block section after calling the UNDO COMMAND to restore the polylines as they were before the EXTLPL lisp was executed.

A new DUH function has been added, to restore system variables to their previous settings.

 

Try this modified code:

(prompt "\nTo run a LISP type: EXTLPL")
(princ)
(prompt "\nTo UNDO with restoring variables type: DUH")
(princ)

(setq old_echo (getvar 'cmdecho))
(setq old_osm (getvar 'osmode))
(setq old_nomutt (getvar 'nomutt))

(defun c:EXTLPL ( / thisdrawing temperr e pt obj spt ept dist ss len i)
  (vl-load-com)

  (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
  (setq temperr *error*)
  (setq *error* trap)
  (setvar 'cmdecho 0)
  (setvar 'osmode 512)
  (setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
  (while (or (= e nil) (not (or (= "LINE" (cdr (assoc 0 (entget (car e))))) (= "LWPOLYLINE" (cdr (assoc 0 (entget (car e))))))))
    (if (= e nil)
      (progn
	(prompt "\nNothing was selected. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      (progn
	(prompt "\nSelected entity must be LINE or POLYLINE. Try again...")
	(setq e (nentsel "\nPick the longest LINE or POLYLINE as base for extending:"))
	(princ)
	)
      )
    )
  (vla-startundomark thisdrawing)
  (cond
    ((= "LINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (cadr ept) (cadr spt))
       (progn
	 (command "._xline" "h" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    ((= "LWPOLYLINE" (cdr (assoc 0 (entget (car e)))))
     (command "._point" (cadr e))
     (setq pt (cdr (assoc 10 (entget (entlast)))))
     (entdel (entlast))
     (setq obj (vlax-ename->vla-object (car e)))
     (setq spt (vlax-curve-getStartPoint obj))
     (setq ept (vlax-curve-getEndPoint obj))
     (setq dist (/ (vlax-get-property obj 'Length) 2))
     (setq old_nomutt (getvar 'nomutt))
     (setvar 'nomutt 1)
     (princ "\nSelect the desired LINES or POLYLINES to extend:")
     (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
     (while (= ss nil)
       (setvar 'nomutt old_nomutt)
       (prompt "\nNothing was selected. Try again...")
       (setvar 'nomutt 1)
       (princ "\nSelect the desired LINES or POLYLINES to extend:")
       (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))
       )
     (if (< (vlax-curve-getDistAtPoint obj pt) dist)
       (progn
	 (command "._xline" "h" spt "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq spt (vlax-curve-getStartPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" spt "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       (progn
	 (command "._xline" "v" ept "")
	 (setq elast (entlast))
	 (setq len (sslength ss))
	 (setq i 0)
	 (while (< i len)
	   (if (= (cdr (assoc 0 (entget (ssname ss i)))) "LINE")
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     (progn
	       (setq ept (vlax-curve-getEndPoint (vlax-ename->vla-object (ssname ss i))))
	       (command "._extend" elast "" ept "")
	       )
	     )
	   (setq i (1+ i))
	   )
	 )
       )
     )
    )
  (vla-endundomark thisdrawing)
  (entdel elast)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (setq *error* temperr)
  (prompt "\nThe desired LINES or POLYLINES were extended!")
  (princ)
  )

(defun C:DUH (/ )
  (command "_.undo" "_control" "_none" "_.undo" "")
  (setvar 'cmdecho old_echo)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (prompt "\nDumped Undo History.")
  (princ)
)

;; Error trap

(defun trap (errmsg)
  (if (not (member errmsg '("console break" "quit / exit abort" "Function Cancelled"))
	   )
    (princ (strcat "\nError: " errmsg ". Resetting Enviroment!"))
    )
  (setq i 0 ss nil len nil)
  (setvar 'osmode old_osm)
  (setvar 'nomutt old_nomutt)
  (setvar 'cmdecho old_echo)
  (terpri)
  (setq *error* temperr)
  (princ)
  )

 

Posted (edited)
15 minutes ago, Saxlle said:

Try this modified code:

that works perfectly for me! I really appreciate your help; it’s made my work so much easier.

 

Some times I have to use AutoCAD LT, and since I can’t load LISP, do you have any suggestions for customizing it in other ways?

 

Also, is there a way to skip the reverse command and have it automatically detect the direction?

Edited by harimaddddy
Posted
5 hours ago, harimaddddy said:

that works perfectly for me! I really appreciate your help; it’s made my work so much easier.

 

Some times I have to use AutoCAD LT, and since I can’t load LISP, do you have any suggestions for customizing it in other ways?

 

Also, is there a way to skip the reverse command and have it automatically detect the direction?

Glad to hear that, you're welcome 🙂.

 

So, if you are using an earlier versions before AutoCAD LT 2024, you definitely can't run a LISP. For now, i don't have any alternative on which way you can do that, instead of using regular commands in AutoCAD LT and to do it manually.

 

For skiping a REVERSE command, i need to find a solution (i can't promise to you when it will be, but i will let you know if i change the original code). But, it is a good practice to learn "drawing" Lines or Polylines (maybe it souds funny, but believe me i have seen a lot of unusual things when people drawing something), because it is not the same if you draw something from top to the bottom, bottom to the top, etc. in order to achieve something wtih that and the way how Lines or Polylines behaves while using them (when you want to do automatization with lisp). Sometimes, it is much easier to use built-in function in AutoCAD before using maded .lsp file to accomplish a job, right? 🙂 

 

Best regards.

Posted
3 hours ago, Saxlle said:

So, if you are using an earlier versions before AutoCAD LT 2024, you definitely can't run a LISP. For now, i don't have any alternative on which way you can do that, instead of using regular commands in AutoCAD LT and to do it manually.

Yeah unfortunately it 2022 🥲, So bad brother.

 

3 hours ago, Saxlle said:

For skipping a REVERSE command

That's not a problem brother! I usually draw polylines on the right side, and I rarely do it facing left. So, I would prefer to use the reverse command. But I've learned something new from you, which is great! I'm not really into coding; I'm just a beginner, so I understand things better when I can compare how the code works.

 

3 hours ago, Saxlle said:

Sometimes, it is much easier to use built-in function in AutoCAD before using maded .lsp file to accomplish a job, right?

Correct bro, Thanks a lot.💥

Posted
6 hours ago, harimaddddy said:

That's not a problem brother! I usually draw polylines on the right side, and I rarely do it facing left. So, I would prefer to use the reverse command. But I've learned something new from you, which is great! I'm not really into coding; I'm just a beginner, so I understand things better when I can compare how the code works.

 

Glad to hear that. Feel free to ask if you need something inside the code (explanation, etc.).

 

6 hours ago, harimaddddy said:

Correct bro, Thanks a lot.💥

You're welcome.

 

Best regards.

Posted

"it depends on which "direction" the polylines are drawn" the code above is almost there, what I use and have done so for like 30+ years, is pick an object end, this returns 3 points the pick point, start & end you compare the distance of pt->end pt->start and can then work out if need to reverse the line or pline, NOTE Bricscad does not have Reverse, have not checked V25.

 

Reverse "This is not a BricsCAD command. Have you tried PEDIT with the suboption Reverse direction?"

 

An example this would be a line answer.

(setq ent (entsel "\nPIck object near end Enter to exit "))
  (setq pt (cadr ent))
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car ent)))))
  (setq obj2 (vlax-ename->vla-object (car ent)))
  (setq start (vlax-curve-getstartPoint obj2))
  (setq end (vlax-curve-getendPoint obj2))
  (setq d1 (distance pt start))
  (setq d2 (distance pt end))
  (if (> d1 d2)
  (setq tmp start
    start end
    end tmp
  )

 

 

  • Thanks 1
Posted
On 28/10/2024 at 23:24, BIGAL said:

"it depends on which "direction" the polylines are drawn" the code above is almost there, what I use and have done so for like 30+ years, is pick an object end, this returns 3 points the pick point, start & end you compare the distance of pt->end pt->start and can then work out if need to reverse the line or pline

Thank you @BIGAL, you gave me an idea how can implement a "polyline direction" inside the base code.

 

On 28/10/2024 at 23:24, BIGAL said:

Reverse "This is not a BricsCAD command. Have you tried PEDIT with the suboption Reverse direction?"

Yes, when type PEDIT, there is suboption to "Reverse" a polyline, it works in the same way as "Reverse" command.

 

Best regards.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...