Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Offset to Any Layer

7 REPLIES 7
Reply
Message 1 of 8
Kent1Cooper
3690 Views, 7 Replies

Offset to Any Layer

In the recent thread involving Offsetting to the current Layer, I learned that in newer versions of AutoCAD the Offset command has a Layer option that lets you choose to put the newly-created entity on either the Current Layer or the Layer of the Source entity.  That inspired me to enhance my old Offset-to-Layer routine, adding a similar Current-Layer option to it [and refined some other elements while I was in there].  The enhanced version is attached -- OffsettoLayer.lsp [command name: OL].

 

It's like regular Offset except that it gives you the choice to put the new entity not just on the Current Layer [an enhancement in itself for those with older versions without that option], but on ANY Layer that exists in the drawing, regardless of the Layer of the selected object or of whatever Layer happens to be current.  [It doesn't offer the Source object's Layer -- for that, just use regular Offset.]

 

It lets you try again if you give it a non-existent Layer name, or pick something that can't be Offset, or something on a locked Layer.  See other comments at the top of the file.

 

[A "negative" difference from regular Offset is that you need to use Escape to exit -- space/Enter won't do it, but will ask you again to select an object.  I'll keep thinking about whether it can be made to end with space/Enter as well as Esc, and still do everything else right.]

 

One choice that I made was to have it save its own offset distance [or Through] setting, independent of regular Offset's default [the OFFSETDIST System Variable].  So you can use OL, then use regular Offset with a different setting, and go back to OL and it will offer the value you used in it before as the default.  And when you go back to regular Offset, it still has its own default, unaffected by the use of OL.  I'd be interested in whether people feel that's a useful approach, or think it would be better to let OL and regular Offset each affect the default distance/Through value offered by the other.

Kent Cooper, AIA
7 REPLIES 7
Message 2 of 8
scot-65
in reply to: Kent1Cooper

I tend to use the OFFSETDIST variable instead of creating a separate gremlin.

 

Ergonomics I follow include the following:

If the supplied answer is obtained by keyboard, first enter the answer before selecting objects.

If the answer is obtained by selecting something on the screen, then the following is observed:

a) Match one object to another (MATCHPROP command) by selecting the object with the answer

first, then select objects one at a time that require change.

b) Select many objects first (SSGET), then select the object with the answer.

 

For your program you are going back and fourth between the keyboard, to the screen,

then back to the keyboard to supply the layer answer (like the CHPROP command).

 

If I were to design this, have the user enter on the keyboard or [Select an object/Current layer]

that will be the destination layer first, then OFFSET as usual. This way, when returning to the

command the user will "OL" [Enter] [Enter] and continue with the (internal) OFFSET command

until finished.

 

Below is a partial screen capture of our Screen Menu.

As you can see, I have tailored for typical situations for the site plan.

Some ask for the distance, while others are automatic (3" for fence line)...

This "Offset As" section appears in all of our Screen Menus for every layer group

(plan, elevation, etc.) we employ, and provides typical offsets for that layer group.

 

       4e0cb07e.gif

 

Nice program you have there Kent.


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 8
Anonymous
in reply to: Kent1Cooper

Nice program Kent, I came across one some years back, not written by me, that does something similiar,  It uses the offsetdist variable which I don't have a problem with.  I like to look at code and see the differences in code writing.  The one I have is one third the code than yours (not a criticism) so I get to look at different writing ideas and error handling.

Message 4 of 8
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

Nice program Kent, I came across one some years back, not written by me, that does something similiar,  It uses the offsetdist variable which I don't have a problem with.  ....  The one I have is one third the code than yours (not a criticism) so I get to look at different writing ideas and error handling.


Much of the length of mine, in addition to error handling, has to do with ensuring a few things -- that the Layer entered exists, and mostly that the object selected can be offset.  If your shorter one is similar to the offset-to-the-current-layer routine at the top of this thread:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Why-does-the-last-offset-to-current-layer-revert-to-the-original/td-p/3074980

 

it will run into a problem if the first thing selected to offset is on a locked Layer.  It will ask you to pick again, then after you do, change the last object in the drawing [whatever it may be, probably unrelated to what you're doing] to the designated Layer, and not offset the non-locked-Layer thing you just picked, and then ask you to pick again for the next go-round.  It's all because of the extra prompts in how regular Offset handles things that can't be offset for whatever reason [and it doesn't handle them all the same, either -- for things on locked Layers, Text, or 3D Splines, it tells you as soon as you pick the object, but it doesn't tell you it won't offset a 3DPolyline until you tell it which side to offset it to].

 

If you'd rather not have OL retain its own distance/Through setting independently of regular Offset and leave regular Offset's alone, but would rather have each affect the default for the other, attached is a version like that, but "protected" against that particular problem.

Kent Cooper, AIA
Message 5 of 8
Anonymous
in reply to: Kent1Cooper

Thanks for the reply.  Mine doesn't create a layer if the layer doesn't exist, but I have my layers loaded from my template so I don't have that problem and I really don't use locked layers unless I am doing plan and profile work.  I hate trying to pick a line and I get the profile grid lines.  Civil3D is changing all that.  I usually write programs for the way I do my tasks and don't get very elaborate on error handling and what ifs but I do like to see how other people do things to get ideas for the next program I may write.  Thanks again.

Message 6 of 8
scot-65
in reply to: Anonymous

Apologies to Kent for my earlier less-than-accurate reply as I did not have AutoCAD turned

on and was confused by 2k worth of program with 3k worth of comments. I got lost.

 

Well, anyways, to make up for this, have a look at what I created.

The one issue that always bothered me is when one misses the

entity when using ENTSEL. The program simply stops. This is so

true when using the OFFSET command rather quickly.

 

We do not lock layers (either), so this part was not incorporated into the program.

 

🙂


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 7 of 8
rhgrafix
in reply to: scot-65

 I use small offsets to counter the laser kerf so I have to make a lot of them, your macro allows me to do multiple, then freeze my true sized objects. The only thing I would change is to allow our standard pickbox, the little x is hard for my not-as-good eyes to pick the entities. Good job and thank you!

Message 8 of 8
rhgrafix
in reply to: Kent1Cooper

There we go! This is my fave of the 3 on this page, has multiple and keeps my pickbox! Thanks much!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report