DavidgGBS Posted June 21, 2013 Share Posted June 21, 2013 I have the following code to draw a fixed-width rectangle with the length of a given line: (command "RECTANGLE" (list (car start) (- (cadr start) 0.33)) (list (+ (car start) (distance start end)) (+ (cadr start) 0.33))) For some reason, though, the rectangles are starting at the line's start point rather than 0.33 units lower. My X and Y values are in the millions, in case that helps identify it as an overflow error. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 22, 2013 Share Posted June 22, 2013 So what is the problem with that ? Quote Link to comment Share on other sites More sharing options...
fixo Posted June 22, 2013 Share Posted June 22, 2013 Try to take this code as basic, then add your changes to the variables (defun C:MREC (/ dxf ang ang+ dis elist em_list end ln pi_2 pts pt_lr pt_ur start) (defun dxf (key alist)(cdr (assoc key alist))) (while (setq ln (entsel "\nSelect line: ")) (progn (setq ln (car ln) elist (entget ln) start (dxf 10 elist) end (dxf 11 elist) ang (angle start end) dis (distance start end) pi_2 (/ pi 2.0) ang+ (+ ang pi_2) pt_ur (polar end ang+ dis) pt_lr (polar start ang+ dis)) (setq pts (mapcar '(lambda(p)(list (car p) (cadr p))) (mapcar '(lambda(q) (trans q 1 0))(list start end pt_ur pt_lr)))) (setq em_list (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") ;(cons 8 "0")) (cons 90 (length pts)) (cons 70 1) ) (mapcar '(lambda (p) (list 10 (car p) (cadr p)))pts) ) ) (if (entmake em_list) (entupd (entlast)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 22, 2013 Share Posted June 22, 2013 This works fine for me: ;; <snip> (if (and (setq start (trans (getpoint) 1 0)) (not (initget 32)) (setq end (trans (getpoint start) 1 0)) ) (command "RECTANGLE" (list (setq x (car start)) (- (setq y (cadr start)) 0.33) (last start) ) (list (+ x (distance start end)) (+ y 0.33) (last end)) ) ) ;; <snip> ** TRANS not required. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 22, 2013 Share Posted June 22, 2013 ** TRANS not required. But maybe off snap is required with the command call ! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 22, 2013 Share Posted June 22, 2013 (edited) But maybe off snap is required with the command call ! You mean "_non"? Sure if you like. [Edit] - Again, not required... The first point is the CENter of a circle.... Sorry, wrong thread. Edited June 22, 2013 by BlackBox Quote Link to comment Share on other sites More sharing options...
fixo Posted June 22, 2013 Share Posted June 22, 2013 Sorry for my stupidity, perhaps like this (if (and (setq start (trans (getpoint) 1 0)) (not (initget 32)) (setq end (trans (getpoint start) 1 0)) ) (progn (command "RECTANGLE" "_non" (list (setq x (car start)) (- (setq y (cadr start)) 0.33) (last start) ) "_non"(list (+ x (distance start end)) (+ y 0.33) (last end)) ) (command "_rotate" "L" "" "_non" start (/ (* (angle start end) 180) pi))) ) Quote Link to comment Share on other sites More sharing options...
DavidgGBS Posted June 24, 2013 Author Share Posted June 24, 2013 Adding "_non" did it! Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.