hgcwh Posted June 1, 2012 Posted June 1, 2012 Hi, I created a rectangular using 4 points. Then is there a way to assign 2 vertical lines into 2 variables Line_1/Line_2 automatically instead of manually picking these 2 lines using (setq Line_1 (entsel "choose 1st line:)). Many thanks Jay Quote
Lee Mac Posted June 1, 2012 Posted June 1, 2012 If you created the lines using the command function, use entlast to collect the last entity added to the database; otherwise, use entmakex and the entity name of the created entity will be returned by the function. Welcome to CADTutor Jay. Quote
asos2000 Posted June 3, 2012 Posted June 3, 2012 Option (defun c:rec1 (/ pt1 pt2 pt3 pt4) (setq pt1 (getpoint "\n click first corner")) (setq ortmd (getvar "orthomode")) (setvar "orthomode" 0) (setq pt2 (getcorner pt1 "\n click second corner")) (setvar "orthomode" ortmd) (command "rectang" pt1 pt2 "") (setq pt3 (list (car pt2) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt2))) (command "line" pt1 pt2 "") (command "line" pt3 pt4 "") ) Another one (defun c:rec2 (/ pt1 pt2 pt3 pt4) (setq pt1 (getpoint "\n click first corner")) (setq ortmd (getvar "orthomode")) (setvar "orthomode" 0) (setq pt2 (getpoint pt1 "\n click second corner")) (setvar "orthomode" ortmd) (setq pt3 (list (car pt2) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt2))) (LWPoly pt1 pt3 pt2 pt4) (Line pt1 pt2) (Line pt3 pt4) ) (defun LWPoly (p1 p2 p3 p4) (entmakex (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 4) (cons 70 1) (cons 10 p1) (cons 10 p2) (cons 10 p3) (cons 10 p4) ))) (defun Line (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))) Quote
asos2000 Posted June 3, 2012 Posted June 3, 2012 Another one Only one closed LWPoly (defun c:rec3 (/ pt1 pt2 pt3 pt4) (setq pt1 (getpoint "\n click first corner")) (setq ortmd (getvar "orthomode")) (setvar "orthomode" 0) (setq pt2 (getpoint pt1 "\n click second corner")) (setvar "orthomode" ortmd) (setq pt3 (list (car pt2) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt2))) (setq lst (list pt1 pt3 pt2 pt4 pt1 pt2 pt4 pt3)) (LWPoly lst) ) (defun LWPoly (lst) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 1) ; closed LWPoly ) (mapcar (function (lambda (p) (cons 10 p))) lst)))) Quote
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.