Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all:
Please help me see the error of my ways:
This little routine to draw an oft-drawn shape in AutoCAD works as intended unless I select a point on another block, shape, entity when choosing the startpoint. To be clear, when I select the startpoint in space without snapping it to another entity, it draws the pline shape as intended and rotates it to the angle specified, but I really need this to work when attached to something else as that is the end use.
Feel free to criticize my coding structure/methods as I am just starting to learn AutoLISP.
(defun c:BUSH ( / bushstart bushend bushangle startpoint)
(setq bushstart (getdist "\nEnter start size: "))
(setq bushend (getdist "\nEnter end size: "))
(setq bushangle (getangle "\nEnter rotation: "))
(initget 129)
(setq startpoint (getpoint "\npick location of first point: "))
; (alert (strcat "Bushing will be " bushstart " by " bushend "\nRotated " bushangle " degrees. \nlocated at " startpoint))
(setq x_val (car startpoint) )
(setq y_val (cadr startpoint) )
(setq y_val1 (+ 0.5 y_val) )
(setq y_val2 (+ 1 y_val) )
(setq x_val1 (- x_val (/ bushstart 2)))
(setq x_val2 (- x_val (/ bushend 2)))
(setq x_val3 (+ x_val (/ bushstart 2)))
(setq x_val4 (+ x_val (/ bushend 2)))
(setq pt2 (list x_val1 y_val))
(setq pt3 (list x_val1 y_val1))
(setq pt4 (list x_val2 y_val1))
(setq pt5 (list x_val2 y_val2))
(setq pt6 (list x_val4 y_val2))
(setq pt7 (list x_val4 y_val1))
(setq pt8 (list x_val3 y_val1))
(setq pt9 (list x_val3 y_val))
(setq rotang (* 180.0 (/ bushangle pi)))
(command "_.layer" "_set" "0" "")
(command "pline" startpoint "w" "0" "0" pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 startpoint "")
(command "rotate" (entlast) "" startpoint rotang)
(setq rotang)
(princ)
)
AutoCAD 2024 on Windows 11.
Solved! Go to Solution.