mid and end points of lines and arcs

mid and end points of lines and arcs

dario_jukica
Contributor Contributor
2,086 Views
29 Replies
Message 1 of 30

mid and end points of lines and arcs

dario_jukica
Contributor
Contributor

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

0 Likes
Accepted solutions (2)
2,087 Views
29 Replies
Replies (29)
Message 21 of 30

dario_jukica
Contributor
Contributor

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)
)

 

0 Likes
Message 22 of 30

ВeekeeCZ
Consultant
Consultant

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

0 Likes
Message 23 of 30

dario_jukica
Contributor
Contributor

I use a decimal point.

0 Likes
Message 24 of 30

ВeekeeCZ
Consultant
Consultant

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

 

0 Likes
Message 25 of 30

dario_jukica
Contributor
Contributor

Very good.

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

 

Thank you very much.

0 Likes
Message 26 of 30

ВeekeeCZ
Consultant
Consultant
Accepted solution

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

 

0 Likes
Message 27 of 30

dario_jukica
Contributor
Contributor

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

0 Likes
Message 28 of 30

ВeekeeCZ
Consultant
Consultant

OK. Do whatever you need to do.

0 Likes
Message 29 of 30

dario_jukica
Contributor
Contributor

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

Cheers

0 Likes
Message 30 of 30

Sea-Haven
Mentor
Mentor

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.

0 Likes