Offset multiple objects in the same layer at once? Or in general, is it possible to apply a command to every object in their layer at once?

Offset multiple objects in the same layer at once? Or in general, is it possible to apply a command to every object in their layer at once?

Mylo.Wilson9SSEG
Observer Observer
10,953 Views
10 Replies
Message 1 of 11

Offset multiple objects in the same layer at once? Or in general, is it possible to apply a command to every object in their layer at once?

Mylo.Wilson9SSEG
Observer
Observer

Title says it all. Basically, I have an alignment that I want to offset. It is composed of three different layers for curves, transitions, and straights. I want to offset each of these by chosen amounts. Can I offset multiple objects in the same layer at once? 

Cheers

0 Likes
Accepted solutions (1)
10,954 Views
10 Replies
Replies (10)
Message 2 of 11

jamalflash
Observer
Observer

certainly you can't do that, but you may find a lisp files to do this step partly.

0 Likes
Message 3 of 11

imadHabash
Mentor
Mentor

Hi,

>> Can I offset multiple objects in the same layer at once? 

Not applicable .. 

Imad Habash

EESignature

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here I have a simple LISP that will offset multiple objects. 

The all layer selection could be done using the SelectSimilar command - simple enough.

 

(vl-load-com)

(defun c:OffsetMultiple ( / s d a i e p r)

  (if (and (setq s (ssget "_:L" '((0 . "LINE,LWPOLYLINE,ARC"))))
	   (setq d (getdist "\nSpecify offset  distance: "))
	   (not (initget "Left"))
	   (setq a (* pi (if (getkword "\nSpecify side [Left] <right>: ")
			   0.5
			   1.5)))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq p (vlax-curve-getstartpoint e))
      (setq r (polar p (+ a (angle '(0 0 0) (vlax-curve-getFirstDeriv e (vlax-curve-getstartparam e)))) 1.))
      (command "_.offset" d e (trans r 0 1) "")))
  (princ)
  )

 

Message 5 of 11

Kent1Cooper
Consultant
Consultant

@Mylo.Wilson9SSEG wrote:

.... I have an alignment that I want to offset. It is composed of three different layers for curves, transitions, and straights. I want to offset each of these by chosen amounts. Can I offset multiple objects in the same layer at once? ....


Welcome to these Forums!

 

"Alignment" is not a kind of object in plain AutoCAD.  If an "alignment" is a specialty object under something like the Civil3D or Map overlay programs, you could ask at the Forum dedicated to that software.  If you mean something else in native AutoCAD object types, describe it again -- what kind(s) of objects [Lines? Arcs? Polylines? Ellipses? Splines?], etc.  I'm especially curious about what "transitions" are if they are not either "curves" or "straights."  A small sample drawing would answer many questions.

 

The difficulty in multiple-object Offset is to determine to which side a given object needs to be Offset [unless you want to go both ways].  If "curves, transitions, and straights" are all on different Layers, then presumably things are not in collective objects [such as Polylines] that can be Offset in their entirety.  Offsetting in an automated way [including @ВeekeeCZ 's suggestion above] is almost sure to Offset some of those pieces in the opposite direction from others whose ends they touch, depending on the drawn direction of each piece, so you would need to pin down some criteria for deciding the directions.

 

It's possible something like this already exists that you could Search for in the >Customization Forum<.

Kent Cooper, AIA
0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
....

The difficulty in multiple-object Offset is to determine to which side a given object needs to be Offset ....


But if you have control over that problem [you know all the things you want to Offset were drawn in the same direction, you know what that is, etc.], here's a really comprehensive routine -- OffsetMultObj.lsp with its OM command -- to Offset Multiple Objects by the same distance to the same side [Left vs. Right] for each.  It accepts any object type that is Offsettable, remembers your choices, and so on -- see the comments at the top and some within the code.

 

I discovered some interesting little things in the process:

You can't use (vla-offset) on a Ray, though they are Offsettable with the command; but you can on an Xline, which I would have thought would be handled similarly to a Ray.

It is possible for the Offset command's distance value to be set to 0 [but this command doesn't allow it].

A positive value in (vla-offset) goes to the Left for Lines and Xlines, but to the Right for other things.

Kent Cooper, AIA
0 Likes
Message 7 of 11

IdanGorali
Community Visitor
Community Visitor

Great lisp! been using it a lot!, is there a possibility to erase the original object after the offset is done?

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

@IdanGorali wrote:

... is there a possibility to erase the original object after the offset is done?


If you have the Offset command set to Erase the source object, then that will happen in this command to Rays, since [because (vla-offset) doesn't work on them] it uses an Offset command on those, and so honors that setting.  That could be built into the command function for them.  If it's not currently set that way, should that state be restored afterwards?

 

But (vla-offset) used on everything else does not honor that setting.  If a simple (vla-delete) on the source object were included, it would cause an error with Rays, since the Offset command would have removed the source.  So I think (vla-delete) would need another check on entity type, or be included only in the other-than-Ray operation, but coordinated into the check on whether it could Offset an object inward by the specified distance.  For things not Offsettable inward like that, would you want the source object deleted, or [my guess] kept?

 

I'm sure it's doable -- I just need to work it out, subject to answers to the two questions above.

Kent Cooper, AIA
0 Likes
Message 9 of 11

IdanGorali
Community Visitor
Community Visitor

1. I admit i do not use Rays, but i assume that if the Offset command isn't set to erase that it should be reset after the use of the lisp.

2. I would like to keep the original if it is impossible to offset the desired distance, or better, have an option to set whether to erase in this case or not.

 

Thank you very much!

0 Likes
Message 10 of 11

daniel_A8GD7
Observer
Observer

Hello, 

 

This lisp works great to offset polylines, but I was wondering about how I could implement the delete source feature. Is it possible with plines and this lisp? The offset I am doing is outward (right in the lisp command). 

 

Thanks you

0 Likes
Message 11 of 11

gianfrancolongo01
Explorer
Explorer

Thank you so much! It worked very well for my purpose. 🤝

0 Likes