Offset multiple elements in a single operation

Offset multiple elements in a single operation

JB-T
Enthusiast Enthusiast
8,122 Views
10 Replies
Message 1 of 11

Offset multiple elements in a single operation

JB-T
Enthusiast
Enthusiast

Hi,

 

I found an awesome routine that allow me to offset multiple elements in a single operation, but I cannot choose the orientation for the offset...

 

Is it possible to edit this routine in order to be able to identify in which direction I want my offset to be done?

 

 

(defun c:mOff (/ ss tmp safe lst)
(vl-load-com)
(or *moff (setq *moff 10.0))
(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(if (setq ss (ssget '((0 . "ARC,CIRCLE,ELLIPSE,*LINE"))))
(progn
(initget 6)
(and (setq tmp (getdist (strcat "\nSpecify Offset <" (vl-princ-to-string *moff) "> : ")))
(setq *moff tmp))
(vla-StartUndoMark doc)
(foreach var (mapcar (function (lambda (x) (vla-offset x *moff)))
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))

(cond ((<= 0 (vlax-safearray-get-u-bound
(setq safe (vlax-variant-value var)) 1))
(setq lst (cons (vlax-safearray->list safe) lst)))))
(foreach Obj (setq lst (apply 'append lst))
(if (vl-some
(function
(lambda (x)
(vlax-invoke obj 'IntersectWith x acExtendNone)))
(vl-remove Obj lst))
(vla-put-color Obj acred)))
(vla-EndUndoMark doc)))

(princ))

 

Thank you for your time!

Accepted solutions (1)
8,123 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

I have this one in my archive... written by @alanjt_

 

(it's probably renamed)

 

Edit: I've attached my slightly modified version to make it more straightforward.

Message 3 of 11

JB-T
Enthusiast
Enthusiast
Thank you, it's a nice one!

Have a good day!
Message 4 of 11

Kent1Cooper
Consultant
Consultant

@JB-T wrote:

.... 

I found an awesome routine that allow me to offset multiple elements in a single operation, but I cannot choose the orientation for the offset...

 

Is it possible to edit this routine in order to be able to identify in which direction I want my offset to be done?

....


How would you want to specify that direction?  Individually for each of the selected objects?  [Then should you just use the basic Offset command?]  Or with a single point that should be used as the to-which-side determinant for all of them?

 

If the latter, I think the routine would need to be altered to use an Offset command [which asks for the side] rather than the (vla-offset) function [which doesn't -- it depends on the direction in which the entity was drawn and goes to one side or the other depending on whether the offset distance is positive or negative].  That should be an easy alteration if that's what you need.

Kent Cooper, AIA
Message 5 of 11

jtm2020hyo
Collaborator
Collaborator

@ВeekeeCZ wrote:

I have this one in my archive... written by @alanjt_

 

(its probably renamed)

 

Edit: I attached my little modified version to make it more straight forward.


thanks for help . you are the best. 

0 Likes
Message 6 of 11

pproestos
Collaborator
Collaborator

A--W--E--S--O--M--E

Autocad rules

Message 7 of 11

alfarizqinurjaman
Observer
Observer

How if have two object, but the distance want to different.. for example like first object the distance 1, and second object the distance 2..

0 Likes
Message 8 of 11

rbarbosa8DQGJ
Advocate
Advocate
Very nice! I was looking for something like that too! Tks a lot!
0 Likes
Message 9 of 11

Sea-Haven
Mentor
Mentor

Feasible enter 1,2,3 will ask object 1 side, object 2 side, object 3 side and so on.

 

; thanks to Lee-mac for this defun
(defun csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
    (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2))))
    (list str)
    )
)
; by alanh Feb 2022
(defun c:muloff ( / offs lst val off)
(setq offs (getstring "\Enter offsets 1,2,3 "))
(setq lst (csv->lst offs))
(foreach val lst
(setq off (atof val))
(command "offset" off (entsel "\nSelect object ") (getpoint "\npick side ") "")
)
(princ)
)
0 Likes
Message 10 of 11

marchand_desclave
Contributor
Contributor

wow thank for this lisp 😍

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

No worries will add to the various offset lisps. Like wise another 1,2,3 would offset 1 object 3 times includes -ve so R & L.

0 Likes