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

mid and end points of lines and arcs

29 REPLIES 29
SOLVED
Reply
Message 1 of 30
dario.jukica
866 Views, 29 Replies

mid and end points of lines and arcs

Hi.

I have a drawing with multiple lines and arcs.

I need to place a point od every line end and every arc end and every arc mid.

Overkill at the end to delete multiple.

 

Please help.

 

Thank you.

 

Kind regards,

Dario

29 REPLIES 29
Message 21 of 30
dario.jukica
in reply to: ВeekeeCZ

This is your code modified to add a label with a prompt to choose a starting value.

Thoughts?

 

(vl-load-com)

(defun c:nobiscumv11 (/ s e i a b c p l startnum)

  (setq startnum (getint "\nEnter the starting label number: "))
  (if (setq s (ssget '((0 . "ARC,LINE"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
        a (vlax-curve-getstartpoint e)
        b (vlax-curve-getendpoint e)
        c (if (= "ARC" (cdr (assoc 0 (entget e))))
        (vlax-curve-getpointatdist e (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2))))
      (foreach p (list a b c)
    (if (and p (not (vl-remove-if-not '(lambda (x) (equal p x 1e-5)) l)))
      (setq l (cons p l))))))
  (foreach p l
    (setq textstr (strcat "" (itoa startnum)))
    (setq textent (entmakex
                   (list (cons 0 "TEXT")
                         (cons 10 (list (+ (car p) 1.0) (+ (cadr p) 1.0) 0.0))
                         (cons 1 textstr)
                         (cons 40 1.25)
                         (cons 7 "STANDARD")
                   )
          ))
    (entupd textent)
    (setq startnum (1+ startnum))
    (entmake (list '(0 . "POINT") (cons 10 p))))
  (princ)
)

 

Message 22 of 30
ВeekeeCZ
in reply to: dario.jukica

What's your country's standard, do you use a decimal point or comma?

Message 23 of 30
dario.jukica
in reply to: dario.jukica

I use a decimal point.

Message 24 of 30
ВeekeeCZ
in reply to: dario.jukica

Try this then.

 

(vl-load-com)

(defun c:nobiscumv11 ( / *error* s e i a b c p l f n)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if f (close f))
    (princ))
  
  (if (and (setq s (ssget '((0 . "ARC,LINE"))))
	   (setq n (1- (cond ((getint "Initial number <1>: ")) (1))))
	   (setq f (open (strcat (getvar 'DWGPREFIX) (vl-string-right-trim ".dwg" (getvar 'DWGNAME)) "-Coord.csv") "w"))
	   (write-line "NAZIV,E(HTRS),N(HTRS),Z" f)								; heading
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    a (vlax-curve-getstartpoint e)
	    b (vlax-curve-getendpoint e)
	    c (if (= "ARC" (cdr (assoc 0 (entget e))))
		(vlax-curve-getpointatdist e (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2))))
      (foreach p (list a c b)
	(if (and p (not (vl-remove-if-not '(lambda (x) (equal p x 1e-5)) l)))
	  (setq l (cons p l))))))
  (foreach p l
    (entmake (list '(0 . "POINT") (cons 10 p)))
    (entmake (list '(0 . "TEXT") (cons 10 (mapcar '+ p '(0.2 0.2 0))) '(40 . 1.25) (cons 1 (itoa (setq n (1+ n))))))
    (write-line (strcat (itoa n) "," (rtos (car p) 2 2) "," (rtos (cadr p) 2 2) "," (rtos (caddr p) 2 2)) f))
  (*error* "end")
  )

 

Message 25 of 30
dario.jukica
in reply to: ВeekeeCZ

Very good.

One final request would be to separate exported values into columns.

 

Thank you very much.

Message 26 of 30
ВeekeeCZ
in reply to: dario.jukica

Well, that was my previous question about...... 

 

(vl-load-com)

(defun c:nobiscumv11 ( / *error* s e i a b c p l f n)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if f (close f))
    (princ))
  
  (if (and (setq s (ssget '((0 . "ARC,LINE"))))
	   (setq n (1- (cond ((getint "Initial number <1>: ")) (1))))
	   (setq f (open (strcat (getvar 'DWGPREFIX) (vl-string-right-trim ".dwg" (getvar 'DWGNAME)) "-Coord.csv") "w"))
	   (write-line "NAZIV;E(HTRS);N(HTRS);Z" f)								; heading
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    a (vlax-curve-getstartpoint e)
	    b (vlax-curve-getendpoint e)
	    c (if (= "ARC" (cdr (assoc 0 (entget e))))
		(vlax-curve-getpointatdist e (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2))))
      (foreach p (list a c b)
	(if (and p (not (vl-remove-if-not '(lambda (x) (equal p x 1e-5)) l)))
	  (setq l (cons p l))))))
  (foreach p l
    (entmake (list '(0 . "POINT") (cons 10 p)))
    (entmake (list '(0 . "TEXT") (cons 10 (mapcar '+ p '(0.2 0.2 0))) '(40 . 1.25) (cons 1 (itoa (setq n (1+ n))))))
    (write-line (strcat (itoa n) ";"
			(vl-string-translate "." "," (rtos (car p) 2 2)) ";"
			(vl-string-translate "." "," (rtos (cadr p) 2 2)) ";"
			(vl-string-translate "." "," (rtos (caddr p) 2 2))) f))
  (*error* "end")
  )

 

Message 27 of 30
dario.jukica
in reply to: dario.jukica

I would like to keep the point as a decimal point but have the values separated into columns.

Message 28 of 30
ВeekeeCZ
in reply to: dario.jukica

OK. Do whatever you need to do.

Message 29 of 30
dario.jukica
in reply to: ВeekeeCZ

Thank you very much once again, you've helped me a lot.

Cheers

Message 30 of 30
Sea-Haven
in reply to: dario.jukica

Are they always a closed shape if so use bpoly make a new pline and number the vertices will be in sequential order, so long as the shape is closed and no miscloses.

 

SeaHaven_0-1678841627835.png

The dwg is a bit to simple as I expect not all shapes will be like the sample, so no code, can you provide a more detailed dwg ? If the dwg is correct say so and easy task to do.

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

Post to forums  

Autodesk Design & Make Report

”Boost