Offset Both Sides, erase originals

Offset Both Sides, erase originals

ВeekeeCZ
Consultant Consultant
2,618 Views
11 Replies
Message 1 of 12

Offset Both Sides, erase originals

ВeekeeCZ
Consultant
Consultant

Hello... simple question about VL.

Digging into Lee Mac's code... I just want to make a minor change.... what is (vla-delete ss) for? Why this does not erase the original objects? What should I change to do that? Thx.

 

(defun c:edb () (c:ebd))
(defun c:ebd ( / *error* of undo doc ss ) ;Ekv Both 

  (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)
)

 

0 Likes
Accepted solutions (1)
2,619 Views
11 Replies
Replies (11)
Message 2 of 12

Ranjit_Singh
Advisor
Advisor
Accepted solution
(defun c:edb () (c:ebd))
(defun c:ebd ( / *error* of undo doc ss ) ;Ekv Both 

  (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 obj))
      
      (setq undo (vla-EndUndoMark doc))))
  (princ)
)
Message 3 of 12

ВeekeeCZ
Consultant
Consultant

Thanks Ranjit,

sure, that is obvious... but still, why there was (vl-delete ss)? What it could be good for in the original code?, HERE

0 Likes
Message 4 of 12

patrick_35
Collaborator
Collaborator

Hi


the (vla-delete ss) clear the selection set.
Indeed, after several uses ssget, if not systematically deletes the selections, it was a mistake at some point.

 

A topic here

 

@+

Message 5 of 12

rkmcswain
Mentor
Mentor

Reference

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 6 of 12

Anonymous
Not applicable

Hi Guys,

 

I dont know much about Lisps and dont know how to program but I have used them and they have helped me a lot. Usually I just copy them and paste them into the command line, and viola!

 

I dont seem to get this one right. It gives me this "(_>" and dont allow me to give any input.

 

Please help this Lisp is exactly wat I need to make a weeks job into a minute job.

 

Thanks Guys!

 

Rossouw

0 Likes
Message 7 of 12

ВeekeeCZ
Consultant
Consultant

Well, then don't! Read about the proper way how to load a lisp HERE

 

Use this code... I've made minor changes in the code.

 

 

 

(vl-load-com)

(defun c:OffsetBothErase ( / *error* of undo doc ss )

  (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 obj))
      
      (setq undo (vla-EndUndoMark doc))))
  (princ)
)
Message 8 of 12

Anonymous
Not applicable

Thanks for the lesson BeekeeCZ.

 

Works like a charm!

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... It gives me this "(_>" and dont allow me to give any input.  ....


That indicates that it's one short of the right number of closing right parentheses to finish up the command definition.  Did you perhaps just miss the last line with its single  )  in copying/pasting?

 

But this revival has inspired me to finish working out my own version of such a thing that I had started on some time ago, the attached OffsetBothSidesErase.lsp with its OBSE command.  Benefits over the routines already on this thread:

 

1.  It also works with Rays.

 

2.  It prevents selection of things on locked Layers [the other ones allow them, and if all things on unlocked Layers are processed before any on locked Layers, it doesn't matter, but encountering one on a locked Layer stops the routines, and any remaining things on unlocked Layers are not processed].

 

3.  It remembers your specified Offset distance [separately from regular Offset's], and offers it as the default on subsequent use, so you don't have to specify it again each time.  On first use [when you haven't specified a distance yet], if regular Offset's setting is other than "Through," it offers that as the default.

Kent Cooper, AIA
0 Likes
Message 10 of 12

BJanecka
Observer
Observer

I realize this is an older thread but hoping someone is willing to help.  I need to keep the original in Kent1Cooper's lisp instead of having it deleted.  I'm not familiar with writing lisp so I'm not sure what needs to change in his file.  Any suggestions on what all needs to be deleted from the file to keep the original?

0 Likes
Message 11 of 12

Kent1Cooper
Consultant
Consultant

Just take out this line:

 

          (vla-delete obj)

 

[And I would suggest changing the file and command names, and the commentary at the top, too.]

Kent Cooper, AIA
0 Likes
Message 12 of 12

BJanecka
Observer
Observer

Thank you

0 Likes