nest1291 Posted July 26, 2018 Posted July 26, 2018 Dear Guys~ Offset inside a polygon. and change appointment layer, many objects. LISP plz. See attatched DWG file. plz. sample.dwg Quote
ronjonp Posted July 26, 2018 Posted July 26, 2018 Using this as a base .. here you go. (defun c:foo (/ _off d o od p s x) ;; RJP » 2018-07-26 ;; Offsets a pline inside or out an places the result on layer '3' (defun _off (o d / r) (cond ((= 'list (type (setq r (vl-catch-all-apply 'vlax-invoke (list o 'offset d))))) (car r))) ) (cond ((and (not (initget "Outside Inside")) (setq p (cond ((getkword "\nOffset [Outside/Inside] <Inside>: ")) ("Inside") ) ) (setq od (cond ((getdist "\nEnter offset distance: <1.5>")) (1.5) ) ) (setq s (ssget ":L" '((0 . "lwpolyline") (-4 . ">") (90 . 2)))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (setq o (mapcar '(lambda (x) (cond ((setq d (_off o (x od))) (list d (vlax-curve-getarea d))))) (list + -) ) ) (cond ((= 2 (length (setq o (vl-remove 'nil o)))) (setq o (vl-sort o '(lambda (r j) (< (last r) (last j))))) (cond ((= p "Outside") (setq o (reverse o)))) (vla-delete (caadr o)) (setq o (entget (vlax-vla-object->ename (caar o)))) ;; Put object on layer '3' (entmod (append o '((8 . "3")))) ) ((and o (mapcar 'vla-delete (mapcar 'car o))) (print "Could not determine inside or out...") ) ) ) ) ) (princ) ) (vl-load-com) 2 Quote
nest1291 Posted July 26, 2018 Author Posted July 26, 2018 Thank you for your response~. correctly worked. thank you thank you~ Quote
sketch11 Posted August 22, 2020 Posted August 22, 2020 (edited) Can anyone make the code by ronjonp work for Lines and Arcs. Edited August 22, 2020 by sketch11 Quote
BIGAL Posted August 23, 2020 Posted August 23, 2020 For a line its easy you pick an end then you compare the start and end of line to the pick point so know direction this results in knowing left or right direction for a offset. for an arc its a + or - offset so resulting in new radius. Quote
Roy_043 Posted August 23, 2020 Posted August 23, 2020 For a selection of lines the task 'Offset inside' makes no sense. 2 Quote
sketch11 Posted August 23, 2020 Posted August 23, 2020 Quote For a selection of lines the task 'Offset inside' makes no sense. OK, I thought the Lines/Arcs may be easier than polygons. It looks like it's not the case. I'll just have to do it item by item. Thanks for the responses. Quote
BIGAL Posted August 24, 2020 Posted August 24, 2020 Looking at your drawing you have asked maybe the wrong question 1st part should be make the plines automatically with a gap and 2nd part do offset at same time. (setq obj (vlax-ename->vla-object (car (entsel "Pick obj")))) ; do this as either (entlast) or a selection (ssname ss x) (vla-offset obj 1.5) (command "chprop" "l" "" "la" "appointment layer" "") Are the panels always 283 wide ? How do you define the outer shape ? Quote
Batuhan Anyığ Posted April 21, 2023 Posted April 21, 2023 (edited) how can i change the layer name of all objects Edited April 21, 2023 by Batuhan Anyığ language is not english Quote
ronjonp Posted April 21, 2023 Posted April 21, 2023 (edited) 1 hour ago, Batuhan Anyığ said: how can i change the layer name of all objects Edited April 21, 2023 by ronjonp Quote
Trap3d Posted July 17, 2023 Posted July 17, 2023 On 7/26/2018 at 3:06 PM, ronjonp said: Using this as a base .. here you go. (defun c:foo (/ _off d o od p s x) ;; RJP » 2018-07-26 ;; Offsets a pline inside or out an places the result on layer '3' (defun _off (o d / r) (cond ((= 'list (type (setq r (vl-catch-all-apply 'vlax-invoke (list o 'offset d))))) (car r))) ) (cond ((and (not (initget "Outside Inside")) (setq p (cond ((getkword "\nOffset [Outside/Inside] <Inside>: ")) ("Inside") ) ) (setq od (cond ((getdist "\nEnter offset distance: <1.5>")) (1.5) ) ) (setq s (ssget ":L" '((0 . "lwpolyline") (-4 . ">") (90 . 2)))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (setq o (mapcar '(lambda (x) (cond ((setq d (_off o (x od))) (list d (vlax-curve-getarea d))))) (list + -) ) ) (cond ((= 2 (length (setq o (vl-remove 'nil o)))) (setq o (vl-sort o '(lambda (r j) (< (last r) (last j))))) (cond ((= p "Outside") (setq o (reverse o)))) (vla-delete (caadr o)) (setq o (entget (vlax-vla-object->ename (caar o)))) ;; Put object on layer '3' (entmod (append o '((8 . "3")))) ) ((and o (mapcar 'vla-delete (mapcar 'car o))) (print "Could not determine inside or out...") ) ) ) ) ) (princ) ) (vl-load-com) Hi @ronjonp your code is great I was testing on some closed plines that i have. if the input pline is a bit of a complex geometry, the resulting offsetted pline can be divided in 2. (see attached example) If that happens, only one of the resulting plines will move to the defined layer. How can the code be modified so all resulting plines are moving to the defined layer? OFFSET_PLINE.dwg Quote
Tharwat Posted July 17, 2023 Posted July 17, 2023 1 hour ago, Trap3d said: How can the code be modified so all resulting plines are moving to the defined layer? Set the defined layer current via (setvar 'clayer "3") then reset it back at the end to previous layer. 1 Quote
marko_ribar Posted July 17, 2023 Posted July 17, 2023 (edited) Or, use this Ron's mod. by me... (defun c:offslws-out-ins-putlayer (/ _off d o od p s x) (vl-load-com) ;; RJP » 2018-07-26 ;; Offsets a pline inside or out an places the result on layer '3' (defun _off (o d / r) (cond ((= 'list (type (setq r (vl-catch-all-apply 'vlax-invoke (list o 'offset d))))) r)) ) (cond ((and (not (initget "Outside Inside")) (setq p (cond ((getkword "\nOffset [Outside/Inside] <Inside>: ")) ("Inside"))) (setq od (cond ((getdist "\nEnter offset distance: <1.5>")) (1.5))) (setq s (ssget ":L" '((0 . "lwpolyline") (-4 . ">") (90 . 2)))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (setq o (append (_off o (+ od)) (_off o (- od)))) (setq o (mapcar '(lambda (x) (list x (vlax-curve-getarea x))) o)) (cond ((>= (length (setq o (vl-remove 'nil o))) 2) (setq o (vl-sort o '(lambda (r j) (> (last r) (last j))))) (cond ((= p "Outside") (mapcar '(lambda (x) (vla-delete (car x))) (cdr o)) (setq o (entget (vlax-vla-object->ename (caar o)))) ;; Put object on layer '3' (entupd (cdr (assoc -1 (entmod (subst (cons 8 "3") (assoc 8 o) o))))) ) ((= p "Inside") (entdel (vlax-vla-object->ename (caar o))) (setq o (cdr o)) ;; Put object(s) on layer '3' (mapcar '(lambda (x) (entupd (cdr (assoc -1 (entmod (subst (cons 8 "3") (assoc 8 x) x)))))) (mapcar '(lambda (y) (entget (vlax-vla-object->ename y))) (mapcar 'car o) ) ) ) ) ) ((and o (mapcar 'vla-delete (mapcar 'car o))) (print "Could not determine inside or out...") ) ) ) ) ) (princ) ) HTH., M.R. Edited July 17, 2023 by marko_ribar 1 Quote
Trap3d Posted July 17, 2023 Posted July 17, 2023 Thank you @Tharwat and @marko_ribar. It worked just fine, I got what i needed 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.