ohhong2 Posted July 18, 2023 Posted July 18, 2023 Hello everyone. I found a function on the internet that creates a square. I want to make the polyline rectangle to the wipeout rectangle. How is this possible? I thought I could just replace (list '(0 . "LWPOLYLINE") with (list '(0 . "WIPEOUT"). but it doesn't work. Thanks. Source code - below (defun make () (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) )) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 1) (cons 8 "0") (cons 38 0.0) (cons 210 (list 0.0 0.0 1.0)) ) (mapcar '(lambda (pt) (cons 10 pt)) vertexList) ) ) ) Quote
mhupp Posted July 18, 2023 Posted July 18, 2023 (edited) https://adndevblog.typepad.com/autocad/2012/05/lisp-entmakeing-a-wipeout-object-in-autocad-gives-different-coordinates-than-expected.html Edited July 18, 2023 by mhupp 1 Quote
ohhong2 Posted July 18, 2023 Author Posted July 18, 2023 22 minutes ago, mhupp said: https://adndevblog.typepad.com/autocad/2012/05/lisp-entmakeing-a-wipeout-object-in-autocad-gives-different-coordinates-than-expected.html Thank you for your kind reply. But aren't you talking about coordinates? I'm using the above function to create a polyline just fine. and I want to turn that polyline into a wipeout object. But what you said is very helpful, thank you. Quote
ohhong2 Posted July 18, 2023 Author Posted July 18, 2023 Example of replacing polyline with wipeout... It's not working.. example) (defun make () (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) )) (entmake (append (list '(0 . "WIPEOUT") '(100 . "AcDbEntity") '(100 . "AcDbWipeout") (cons 90 (length vertexList)) (cons 70 1) (cons 8 "0") (cons 38 0.0) (cons 210 (list 0.0 0.0 1.0)) ) (mapcar '(lambda (pt) (cons 10 pt)) vertexList) ) ) ) Quote
marko_ribar Posted July 18, 2023 Posted July 18, 2023 You gave simple example, thus it was not hard to construct WIPEOUT through (entmake)... So for complex ones, I strongly suggest that you use first code which will convert lwpolyline into wipeout with the same characteristics... (defun c:makewipeout ( / vertexList lw ) (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq lw (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") (cons 8 "0") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 (1+ (* 128 (getvar 'plinegen)))) (cons 38 0.0) ) (mapcar '(lambda ( pt ) (cons 10 pt)) vertexList) (list (list 210 0.0 0.0 1.0)) ) ) ) (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") (princ) ) Or alternatively using (entget (car (entsel))) from previously generated WIPEOUT : ((-1 . <Entity name: 4ac03910>) (0 . "WIPEOUT") (5 . "AA") (330 . <Entity name: 4a5381c0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbWipeout") (90 . 0) (10 -1.0 -1.0 0.0) (11 2.0 0.0 0.0) (12 0.0 2.0 0.0) (13 1.0 1.0 0.0) (70 . 7) (280 . 1) (281 . 50) (282 . 50) (283 . 0) (71 . 2) (91 . 5) (14 -0.5 0.5 0.0) (14 0.5 0.5 0.0) (14 0.5 -0.5 0.0) (14 -0.5 -0.5 0.0) (14 -0.5 0.5 0.0) (290 . 0)) (defun c:makewipeout ( / vertexListmain vertexList ) (setq vertexListmain (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq vertexList (mapcar '(lambda (x) (mapcar '(lambda (y) (/ y 2.0)) x)) vertexListmain)) (entmake (append (list (cons 0 "WIPEOUT") (cons 100 "AcDbEntity") (cons 100 "AcDbWipeout") (cons 90 0) (cons 10 (car vertexListmain)) (cons 11 (mapcar '- (cadr vertexListmain) (car vertexListmain))) (cons 12 (mapcar '- (caddr vertexListmain) (cadr vertexListmain))) (cons 13 (caddr vertexListmain)) (cons 70 7) (cons 280 1) (cons 281 50) (cons 282 50) (cons 283 0) (cons 71 2) (cons 91 5) ) (mapcar '(lambda (p) (cons 14 p)) (append vertexList (list (car vertexList)))) (list (cons 290 0)) ) ) (princ) ) HTH., M.R. 1 1 Quote
ohhong2 Posted July 18, 2023 Author Posted July 18, 2023 14 hours ago, marko_ribar said: You gave simple example, thus it was not hard to construct WIPEOUT through (entmake)... So for complex ones, I strongly suggest that you use first code which will convert lwpolyline into wipeout with the same characteristics... (defun c:makewipeout ( / vertexList lw ) (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq lw (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") (cons 8 "0") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 (1+ (* 128 (getvar 'plinegen)))) (cons 38 0.0) ) (mapcar '(lambda ( pt ) (cons 10 pt)) vertexList) (list (list 210 0.0 0.0 1.0)) ) ) ) (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") (princ) ) Or alternatively using (entget (car (entsel))) from previously generated WIPEOUT : ((-1 . <Entity name: 4ac03910>) (0 . "WIPEOUT") (5 . "AA") (330 . <Entity name: 4a5381c0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbWipeout") (90 . 0) (10 -1.0 -1.0 0.0) (11 2.0 0.0 0.0) (12 0.0 2.0 0.0) (13 1.0 1.0 0.0) (70 . 7) (280 . 1) (281 . 50) (282 . 50) (283 . 0) (71 . 2) (91 . 5) (14 -0.5 0.5 0.0) (14 0.5 0.5 0.0) (14 0.5 -0.5 0.0) (14 -0.5 -0.5 0.0) (14 -0.5 0.5 0.0) (290 . 0)) (defun c:makewipeout ( / vertexListmain vertexList ) (setq vertexListmain (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq vertexList (mapcar '(lambda (x) (mapcar '(lambda (y) (/ y 2.0)) x)) vertexListmain)) (entmake (append (list (cons 0 "WIPEOUT") (cons 100 "AcDbEntity") (cons 100 "AcDbWipeout") (cons 90 0) (cons 10 (car vertexListmain)) (cons 11 (mapcar '- (cadr vertexListmain) (car vertexListmain))) (cons 12 (mapcar '- (caddr vertexListmain) (cadr vertexListmain))) (cons 13 (caddr vertexListmain)) (cons 70 7) (cons 280 1) (cons 281 50) (cons 282 50) (cons 283 0) (cons 71 2) (cons 91 5) ) (mapcar '(lambda (p) (cons 14 p)) (append vertexList (list (car vertexList)))) (list (cons 290 0)) ) ) (princ) ) HTH., M.R. Thank you for your response. Especially the first code seems to work the way I want. But when I tried to use the first code in a function, it doesn't seem to work. but it doesn't seem to work. It just crashes CAD. Just in case (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") After deleting this part I tried the code and CAD does not exit. And the polyline object is created just fine. I'm trying to use it as an auxiliary function, not defun c:make, but defun make like this. (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") Is this the problem? Quote
ohhong2 Posted July 18, 2023 Author Posted July 18, 2023 42 minutes ago, ohhong2 said: Thank you for your response. Especially the first code seems to work the way I want. But when I tried to use the first code in a function, it doesn't seem to work. but it doesn't seem to work. It just crashes CAD. Just in case (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") After deleting this part I tried the code and CAD does not exit. And the polyline object is created just fine. I'm trying to use it as an auxiliary function, not defun c:make, but defun make like this. (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") Is this the problem? This is not a main function, but a subfunction, so I think it can't save the lw variable to wipe out. Just in case, I tested the code by executing (setq lw (entlast)) to test the code, but it doesn't work. Is there any way? Quote
BIGAL Posted July 19, 2023 Posted July 19, 2023 Worked for me made a pline then ... (command "wipeout" "P" (entlast) "Y") ; Y or N 1 Quote
ohhong2 Posted July 19, 2023 Author Posted July 19, 2023 On 7/19/2023 at 3:21 AM, BIGAL said: Worked for me made a pline then ... (command "wipeout" "P" (entlast) "Y") ; Y or N Thank you so much. Put it in the main function, or just create the polyline in CAD and use the (command "wipeout" "P" (entlast) "Y") directly, the polyline will change to wipeout just fine. and the polyline changes to wipeout just fine. But even if I place the code in below subfunction the generated polyline is not converted to wipeout. Is it because it's a secondary function, not a main function? (defun make() (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) )) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 1) ; 1 closed : 0 open (cons 8 "0") (cons 38 0.0) (cons 210 (list 0.0 0.0 1.0)) ) (mapcar '(lambda (pt) (cons 10 pt)) vertexList) ) ) ) Quote
exceed Posted July 27, 2023 Posted July 27, 2023 google ductisoft JustWipe v.1.0 lisp will helps you. that's free and not encoded so good for studying Quote
SLW210 Posted July 27, 2023 Posted July 27, 2023 Please put your code in code tags (the <> button in the editor). 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.