get vertices number

get vertices number

Anonymous
Not applicable
4,129 Views
21 Replies
Message 1 of 22

get vertices number

Anonymous
Not applicable
My goal is to select the block (test_block), select the cyan polyline, and return the angle and distance (s) to the vertices ahead.
example: if I select the block with attribute 01 it returns me (128.75 42.0185)
attribute block 05 (308.75 42.0185 276.103 12.6343)
attribute block 02 (96.103 12.6343 132.667 23.556) [...]

The function I am creating works but I depend on the verticie ID as I get the correct ID or is there another way to get the result ??

 

(defun c:ang2dist nil
  (setq obj (vlax-ename->vla-object (setq ent (car (entsel ))))) ;;select block/vla
  (setq baseblk (vlax-get obj 'insertionpoint)) ;; base point
  (setq sspline (ssget "_C" (mapcar '+ baseblk '(5 5)) (mapcar '- baseblk '(10 10)) '((0 . "LWPOLYLINE")(8 . "pline")))) ; select pline
  (setq entpline (ssname sspline 0))
  (setq vert (vlax-curve-getendparam entpline)) ;get total verticie
  (setq id 0) ; number verticie id
  (setq dist (- (vlax-curve-getdistatparam entpline (1+ id)) (vlax-curve-getdistatparam entpline id))) ;get dist  verticie id
  (setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv entpline id))) ;get angle verticie -> radian
  (setq lst (list (list (r2d ang) dist))) ; creat list
)
r2d link here >> https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bearing-and-distance-lisp-modification/td-p/9373785

(defun r2d (r) (if (>= (* 180.0 (/ r pi)) 360) (- (* 180.0 (/ r pi)) 360) (* 180.0 (/ r pi))))

 

0 Likes
Accepted solutions (3)
4,130 Views
21 Replies
Replies (21)
Message 21 of 22

Anonymous
Not applicable

Thank you guys, you are the best !!

Message 22 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Thank you guys, you are the best !!


 

You are welcome, Hope you learn from it. That would be the best reward for our good work here.

 

Cheers

 

0 Likes