jim78b Posted August 21, 2022 Share Posted August 21, 2022 Hello, I would need to modify this lisp, currently it brings all polylines thicknesses to 0 (even in blocks). I should bring to 0 thresholds those polylines that have thickness <0, while those that already have it at 0 or> 0 I leave them as they are. (defun c:polywidthzero ( / doc ) (vlax-for block (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (if (eq :vlax-false (vla-get-isxref block)) (vlax-for obj block (if (eq "AcDbPolyline" (vla-get-objectname obj)) (vl-catch-all-apply 'vla-put-constantwidth (list obj 0.0)) ) ) ) ) (vla-regen doc acallviewports) (princ) ) (vl-load-com) (princ) thanks to all Quote Link to comment Share on other sites More sharing options...
lido Posted August 21, 2022 Share Posted August 21, 2022 Replace the line (if (eq "AcDbPolyline" (vla-get-objectname obj)) With the line (if (and (eq "AcDbPolyline" (vla-get-objectname obj)) (< (vla-get-thickness obj) 0)) NOT tested!! 1 Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 21, 2022 Author Share Posted August 21, 2022 Thanks very much ...so this may work ? Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 22, 2022 Author Share Posted August 22, 2022 hello i tested your modification, not work sorry Quote Link to comment Share on other sites More sharing options...
lido Posted August 22, 2022 Share Posted August 22, 2022 Try this ;;Changing the width of all polylines to zero in all blocks in ;;the drawing if the thickness of the polylines is less than zero (DEFUN C:POLY0 (/ ACDC BNAME LSBLK REGE) (setq ACDC (vla-get-activedocument (vlax-get-acad-object))) (vlax-for el (vla-get-blocks ACDC) (setq BNAME (vla-get-name el)) (if (and (eq (vla-get-isxref el) :vlax-false) (eq (vla-get-islayout el) :vlax-false) (/= (substr BNAME 1 1) "*") (wcmatch BNAME "~*|*") (not (vl-position el LSBLK)) ) (setq LSBLK (cons el LSBLK)) ) ) (foreach Obj LSBLK (vlax-for Itm Obj (if (and (vlax-property-available-p Itm "ObjectName") (vlax-property-available-p Itm "Thickness") (= (strcase (vla-get-objectname Itm)) "ACDBPOLYLINE") (< (vla-get-thickness Itm) 0) ) (vla-put-constantwidth Itm (setq REGE 0)) ) ) ) (if REGE (vla-regen ACDC acallviewports)) (princ) ) ;;C:POLY0 1 Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 Thanks i will try ..but i need Aldo outside blocks . Is this lisp work ? Quote Link to comment Share on other sites More sharing options...
lido Posted August 24, 2022 Share Posted August 24, 2022 The program works only for polylines inside the block. For the entities polylines, test the thickness with the function vla-get-thickness (see above). Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 sorry have patience, but i need that works even for polylines outside blocks. Quote Link to comment Share on other sites More sharing options...
lido Posted August 24, 2022 Share Posted August 24, 2022 Try this ;;Changing the width of the polylines to zero if the ;;thickness of the polylines is less than zero (DEFUN C:POLY1 (/ ACDC SEL) (ssget "_X" (list (quote (0 . "*POLYLINE")) (quote (-4 . "<")) (quote (39 . 0)))) (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC)) (vlax-for Itm SEL (vla-put-constantwidth Itm 0)) (princ) ) ;;C:POLY1 Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 sorry nothing happen, not work i am so sorry, Quote Link to comment Share on other sites More sharing options...
lido Posted August 24, 2022 Share Posted August 24, 2022 For my it works! Please test the program on the attached dwg. Depending on your CAD program, maybe a regeneration of the drawing might be necessary (?) Test.dwg Quote Link to comment Share on other sites More sharing options...
mhupp Posted August 24, 2022 Share Posted August 24, 2022 locked layers?? Quote Link to comment Share on other sites More sharing options...
lido Posted August 24, 2022 Share Posted August 24, 2022 @mhupp Replace (vla-put-constantwidth Itm 0) with (vl-catch-all-apply (function vla-put-constantwidth) (list Itm 0)) Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 ;;Changing the width of the polylines to zero if the ;;thickness of the polylines is less than zero (DEFUN C:POLY0 (/ ACDC SEL) (ssget "_X" (list (quote (0 . "*POLYLINE")) (quote (-4 . "<")) (quote (39 . 0)))) (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC)) (vlax-for Itm SEL (vl-catch-all-apply (function vla-put-constantwidth) (list Itm 0)) (princ) ) ;;C:POLY0 malformed list function ! Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 I didn't make myself clear. I mean if I have polylines with thickness greater than 0 (blocks and not) I leave them like this. If I have polylines with thickness less than 0 (example 0.001) do I take them to 0. Clear? Quote Link to comment Share on other sites More sharing options...
mhupp Posted August 24, 2022 Share Posted August 24, 2022 0.001 is greater then 0 Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 24, 2022 Author Share Posted August 24, 2022 Oh i am so sorry !excuse i mean ...values like 0.1/ 0.001/0.0001 must be 0. But if i have other polylines that has values different from thath value is ok . So from 0.1 to 0.999999 i think must be 0. Quote Link to comment Share on other sites More sharing options...
mhupp Posted August 24, 2022 Share Posted August 24, 2022 (edited) So update lido's code. ;;Changing the width of the polylines to zero if the ;;thickness of the polylines is less than zero (DEFUN C:POLY0 (/ ACDC SEL) (ssget "_X" '((0 . "*POLYLINE") (-4 . "<=") (39 . 0.1))) ;only select polylines that have widths less than or equal to 0.1 (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC)) (vlax-for Itm SEL (vla-put-constantwidth Itm 0) ) (princ) ) ;;C:POLY0 Edited August 24, 2022 by mhupp less than or equal 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 24, 2022 Share Posted August 24, 2022 41 minutes ago, jim78b said: Oh i am so sorry !excuse i mean ...values like 0.1/ 0.001/0.0001 must be 0. But if i have other polylines that has values different from thath value is ok . So from 0.1 to 0.999999 i think must be 0. Are we talking about THICKNESS or CONSTANTWIDTH ? Quote Link to comment Share on other sites More sharing options...
jim78b Posted August 25, 2022 Author Share Posted August 25, 2022 Constant width 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.