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)
)
Solved! Go to Solution.
Solved by alanjt_. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by _Tharwat. Go to Solution.
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
@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.
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) )