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

Put a point at each end of an Arc

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Patchy
306 Views, 5 Replies

Put a point at each end of an Arc

Hi,

What is the magic word for put a point at each end of an arc, the lisp I have only put a point at center of the arc.

Thank you for helping

 

 

(defun c:PAA ( / i j ss e1 e2 p1 p2 p3 points )

  (if (setq i -1 ss (ssget '((0 . "ARC"))))
    (progn
      (while (setq e1 (ssname ss (setq i (1+ i) j i)))
        (setq points
          (cons (setq p1 (cdr (assoc 10 (entget e1))))
            (cons (setq p2 (cdr (assoc 11 (entget e1)))) points)
          )
        )
        (while (setq e2 (ssname ss (setq j (1+ j))))
          (if (setq p3 (inters p1 p2 (cdr (assoc 10 (entget e2))) (cdr (assoc 11 (entget e2)))))
            (setq points (cons p3 points))
          )
        )
      )
      (while points (entmakex (list (cons 0 "POINT") (cons 10 (car points))))
        (setq points
          (vl-remove-if '(lambda ( x ) (equal (car points) x 1e-8)) (cdr points))
        )
      )
    )
  )
  (princ)
)

5 REPLIES 5
Message 2 of 6
_Tharwat
in reply to: Patchy

Try this ....

 

(defun c:wwe (/ ss i sn vl)
  (vl-load-com)
  ;;; Tharwat 19. Dec. 2011 ;;;
  (if (setq ss (ssget '((0 . "ARC"))))
    (repeat (setq i (sslength ss))
      (setq sn (ssname ss (setq i (1- i))))
      (entmake
        (list
          '(0 . "POINT")
          (cons 10
                (apply 'list
                       (vlax-get (setq vl (vlax-ename->vla-object sn))
                                 'Startpoint
                       )
                )
          )
        )
      )
      (entmake
        (list '(0 . "POINT")
              (cons 10 (apply 'list (vlax-get vl 'Endpoint)))
        )
      )
    )
    (princ)
  )
  (princ)
)

 Tharwat

Message 3 of 6
Kent1Cooper
in reply to: Patchy


@Patchy wrote:

Hi,

What is the magic word for put a point at each end of an arc, the lisp I have only put a point at center of the arc.

....

        (setq points
          (cons (setq p1 (cdr (assoc 10 (entget e1))))
            (cons (setq p2 (cdr (assoc 11 (entget e1)))) points)
          )
        )
....


The (assoc 10) and (assoc 11) values in entity data are appropriate for Lines, but the entity data does not store end-points for Arcs.  It stores the center-point [that's (assoc 10), and where the Point you're getting goes], and the angles [in radians] from there to the start- and end-points.  There is no (assoc 11) entry.  [Do (entget (car (entsel))) and pick an Arc, to see what it says].
 

It's possible to calculate those points from the center and those angles, using (polar), but it's simpler to use (vlax-curve) functions:
 

(setq p1 (vlax-curve-getStartPoint e1))
(setq p2 (vlax-curve-getEndPoint e1))

 

That approach will allow the same function to find the start- and end-points of a Line, Arc, Polyline, Circle, Spline or Ellipse, and even the start-point of a Ray, and perhaps some other things.

 

EDIT:  In comparison to TharwaT's (vlax-get vla-object 'Startpoint), using (vlax-curve-getStartPoint) has the advantage that it will accept an entity name.  You don't need to convert the Arc to a VLA object first.

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

Thank you, you two are MAGICIANS .

Message 5 of 6
_Tharwat
in reply to: Patchy


@Patchy wrote:

Thank you, you two are MAGICIANS .



You're welcome Smiley Very Happy

 

Tharwat

Message 6 of 6
alanjt_
in reply to: _Tharwat

No VL...

 

(defun c:test (/ ss i data ctr rad)
  (if (setq ss (ssget '((0 . "ARC"))))
    (repeat (setq i (sslength ss))
      (setq data (entget (ssname ss (setq i (1- i))))
            ctr  (cdr (assoc 10 data))
            rad  (cdr (assoc 40 data))
      )
      (entmake (list '(0 . "POINT") (cons 10 (polar ctr (cdr (assoc 50 data)) rad))))
      (entmake (list '(0 . "POINT") (cons 10 (polar ctr (cdr (assoc 51 data)) rad))))
    )
  )
  (princ)
)

 

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

Post to forums  

Autodesk Design & Make Report

”Boost