chagri_charapyna Posted July 3, 2021 Posted July 3, 2021 Hi there, I had a code for double offset; I found one code from the forums . I needed an offset for both sides on the line and the code works well. But for the next projects I need to delete the original line and just keep the new 2 side lines. I tried to write something on the code but not works well. Can you check and help me, please ? (defun c:dOff ( / *error* of undo doc ss ) (vl-load-com) (defun *error* ( msg ) (and undo (vla-EndUndomark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (if (and (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE"))) (setq of (getdist "\nSpecify Offset Distance: "))) (progn (setq undo (not (vla-StartUndomark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) ) (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc)) (mapcar (function (lambda ( o ) (vl-catch-all-apply (function vla-offset) (list obj o) ) ) ) (list of (- of)) ) ) (vla-delete ss) (setq undo (vla-EndUndoMark doc)) ) ) (princ) ) Quote
confutatis Posted July 14, 2021 Posted July 14, 2021 (defun c:dOff ( / *error* of undo doc ss ) (vl-load-com) (defun *error* ( msg ) (and undo (vla-EndUndomark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (if (and (setq gru (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))) (setq of (getdist "\nSpecify Offset Distance: "))) (progn (setq undo (not (vla-StartUndomark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) ) (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc)) (mapcar '(lambda ( elem ) (vl-catch-all-apply 'vla-offset (list obj elem)) ) (list of (- of)) ) ) (vla-delete ss) (vl-cmdf "_ERASE" gru "") (setq undo (vla-EndUndoMark doc)) ) ) (princ) ) I set the ssget with the variable gru: (setq gru (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))) The gru selection is deleted: (vl-cmdf "_ERASE" gru "") Aesthetically it's a variation that might make purists cringe and I don't blame them, not least because I try to avoid the command and vl-cmdf function, but it's the one that's much quicker to write. 1 Quote
mhupp Posted July 14, 2021 Posted July 14, 2021 If you don't want to use "vl-cmdf" try the following. (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex gru))) (entdel ent) ) or (repeat (setq i (sslength gru)) (entdel (ssname ss (setq i (1- i)))) ) 2 Quote
mhupp Posted July 14, 2021 Posted July 14, 2021 (edited) 20 minutes ago, confutatis said: Eh, I know, but sometimes laziness... i hear you brother! id probably do the same thing. Edited July 14, 2021 by mhupp 1 Quote
BIGAL Posted July 15, 2021 Posted July 15, 2021 Old fashioned (command "erase" still works. We are talking microseconds for this task. Quote
chagri_charapyna Posted July 15, 2021 Author Posted July 15, 2021 Thank you guys. It fits perfectly to my situation. Thanks a lot. 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.