Aditya Bagaskara Posted February 9, 2023 Posted February 9, 2023 I want to make a rectangle with entmake but somehow it does not work (This code below is supposed to create a rectangle based on a center point) (setq base (getpoint "Set base point") xlen (getreal "Set width") ylen (getreal "Set height") ) (entmake (list (cons 0 "LWPOLYLINE") (cons 10 (list (+ (car base) xlen) (+ (cadr base) ylen) 0.0)) (cons 10 (list (+ (car base) xlen) (- (cadr base) ylen) 0.0)) (cons 10 (list (- (car base) xlen) (- (cadr base) ylen) 0.0)) (cons 10 (list (- (car base) xlen) (+ (cadr base) ylen) 0.0)) )) Can someone please tell me what did I do wrong? Thank you Quote
Emmanuel Delay Posted February 9, 2023 Posted February 9, 2023 Here's a way ;; list of elements to entmake ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ (defun drawLWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst)))) (defun c:rect ( / base xlen ylen) (setq base (getpoint "Set base point: ") xlen (getreal "Set width: ") ylen (getreal "Set height: ") ) (drawLWPoly (list base (list (+ (nth 0 base) xlen) (nth 1 base)) (list (+ (nth 0 base) xlen) (+ (nth 1 base) ylen)) (list (nth 0 base) (+ (nth 1 base) ylen)) ) 1 ) ) Quote
Aditya Bagaskara Posted February 9, 2023 Author Posted February 9, 2023 Sir Emmanuel can you explain to me the minimum dxf code requirements to make a polyline? Thank you Quote
mhupp Posted February 9, 2023 Posted February 9, 2023 Its in his lisp. you have to feed this function a list of points and if you want it to be closed or not (0 or 1) (defun drawLWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) ;if their are 5 points this will be (90 . 5) (cons 70 cls)) ;(70 . 0) open (70 . 1) closed (mapcar (function (lambda (p) (cons 10 p))) lst)))) ;this will make 5 (10 . (x y z)) Quote
BIGAL Posted February 9, 2023 Posted February 9, 2023 Non entmake (defun AHpllst ( lst / x) (command "_pline") (while (= (getvar "cmdactive") 1 ) (repeat (setq x (length lst)) (command (nth (setq x (- x 1)) lst)) ) (command "") ; want closed use "C" ) ) Quote
annadurai Posted January 5 Posted January 5 On 2/9/2023 at 8:44 PM, Emmanuel Delay said: 1 why this 1 is used please clarify Quote
Emmanuel Delay Posted January 5 Posted January 5 4 hours ago, annadurai said: why this 1 is used please clarify That 1 means closed polyline. It's the second parameter given to this function: (defun drawLWPoly (lst cls) ... ) 1 Quote
Steven P Posted January 5 Posted January 5 (edited) For the cons 70, open or closed polyline. Set to 0 to have open, 1 to close, open will give a 'U' shape unless you repeat the first point. (or what he said above, just as I was typing) Edited January 5 by Steven P 1 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.