mdchuyen Posted November 16, 2022 Posted November 16, 2022 Hi guys: I'm new and don't know about autolisp. Sorry to bother you guys, any help is appreciated. And here is the attached drawingtest2.dwg Quote
mhupp Posted November 16, 2022 Posted November 16, 2022 Some reason this is giving me an error. (defun C:Set-poly (/ ss ent cords PtMinY) (if (setq SS (ssget ":L" '((0 . "*POLYLINE")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq cords (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) (setq pMin (_LowYcoord cords)) ) ) ) ;;https://www.cadtutor.net/forum/topic/31382-lowest-y-value-coordinate-for-a-polyline/?do=findComment&comment=289309 (defun _LowYcoord (pointList) (car (vl-sort (mapcar 'eval pointList) '(lambda (a b) (< (cadr a) (cadr b))))) ) Quote
BIGAL Posted November 16, 2022 Posted November 16, 2022 Have a look at this similar request for something I was doing. http://www.theswamp.org/index.php?topic=57938.0 And what I use for CW CCW. ; Checking if pline is CW or CCW and set to CCW ; Orignal idea by Kent Cooper, 1 August 2018 Offsetinorout.lsp ; By Alan H July 2020 (defun AH:chkcwccw (ent / objnew area1 area2 obj minpoint maxpoint) (setq obj (vlax-ename->vla-object ent)) (vla-GetBoundingBox obj 'minpoint 'maxpoint) (setq pointmin (vlax-safearray->list minpoint)) (setq pointmax (vlax-safearray->list maxpoint)) (setq dist (/ (distance pointmin pointmax) 20.0)) (vla-offset obj dist) (setq objnew (vlax-ename->vla-object (entlast))) (setq area1 (vlax-get objnew 'Area)) (vla-delete objnew) (vla-offset obj (- dist)) (setq objnew (vlax-ename->vla-object (entlast))) (setq area2 (vlax-get objnew 'Area)) (vla-delete objnew) (if (> area1 area2) (progn (command "Pedit" ent "reverse" "") ; note bricscad has no REVERSE (setq y (+ y 1)) ) ) ) 2 Quote
mhupp Posted November 17, 2022 Posted November 17, 2022 (edited) Offsetting weird shaped (blue) generates more then one entity when offsetting inside. The green is what would be deleted with (entlast) The white would be left over after running AH:chkcwccw This is what I came up with for Checking Direction. You should only feed this closed polylines because it wouldn't work with open polylines. ;;----------------------------------------------------------------------------;; ;; Checks direction of the pline ;; Orignal idea by Kent Cooper, Alan H ;; https://www.cadtutor.net/forum/topic/76312-change-the-direction-of-multiple-polylines-anti-clockwise-and-fill-in-numbers-in-ascending-order/#comment-603209 (defun CCW (ent / obj dist) (setq obj (vlax-ename->vla-object ent)) (setq dist (vlax-get obj 'Length)) ;get a large distance so that offset inside would error (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list obj 'offset dist))) ;if their is an error offset was to the inside (prompt "\nClockwise") (progn (prompt "\nCounter Clockwise") (entdel (entlast)) ) ) (princ) ) Edited November 17, 2022 by mhupp 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.