Message 1 of 22

Not applicable
07-16-2020
06:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am confused about the return in a function.
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 ??
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))))
Solved! Go to Solution.