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

Offset Macro

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
m_rogoff
879 Views, 15 Replies

Offset Macro

Draw line

Change layer to S-3

Offset .33

(pick the side to offset)

Change layer to S-1

Offset (last) .33

(offset to same side)

Change layer to S-3

 

This is what I have so far:

^C^C-layer;s;S-1;;_line;\\;select;last;;offset;.33;m;\\;;-chprop;p;l;;la;S-3;;

At the first offset command, I get:
Select object to offset or [Exit/Undo] <Exit>:

In order for the macro routine to work, I need to select the "LAST" object. However, Autocad is not recognizing the "LAST" object to be selected. This works when I go step by step, but not as strung together in a macro.
I also have to pick the side to offset twice - is there a way to combine these into one pick?
I found that if I draw the line on the desired layer for the middle object, then CHPROP; previous; last;; this selects the outer two lines (the one originally drawn and the last one offset) and allows me to change the layers.

see the attached .Jpeg for desired results. (Layer S-3 is green, S-1 is red, these layers already exist in the drawing)

 

Thank you

 

P.S. I need a macro, not lisp

15 REPLIES 15
Message 2 of 16
hmsilva
in reply to: m_rogoff

Hi m_rogoff,

 

if your AutoCAD version is not too old, you may also explore the 'Layer' option at OFFSET command...

 

Try

 

^C^C-layer;s;S-1;;_line;\\;_OFFSET;.33;@;\;_CHPROP;L;;LA;S-3;;

 

Hope that helps

Henrique

EESignature

Message 3 of 16
m_rogoff
in reply to: hmsilva

Henrique,

 

   This is what I came up with. When I used the (Layer) and (Multiple) options within the OFFSET command, it would not select the line drawn as the current object. I have to manually select the line twice ( \\;) at the end of the routine, which is not ideal, but still adequate.

 

Ultimate goal is 3 lines, outside 2 are layer S-3, middle is layer S-1

 

^C^C-layer;s;S-3;;_line;\\;_OFFSET;.33;@;\;_CHPROP;L;;LA;S-1;;_OFFSET;L;C;.33;@;\\;

Message 4 of 16
TomBeauford
in reply to: m_rogoff

The lisp function vla-Offset should help it offsets to both sides.  All you need to select is the middle line.

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selecting-object-and-passing-to-vla-o...

 

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
Message 5 of 16
Kent1Cooper
in reply to: TomBeauford


@TomBeauford wrote:

The lisp function vla-Offset should help .... 


... except that they have some Users who use AutoCAD LT and can't do Lisp functions [there's another thread where AutoLISP solutions were suggested, in which we learned that], which is the reason they're aiming for a purely-macro approach [see the end of the first message here].

Kent Cooper, AIA
Message 6 of 16
hmsilva
in reply to: m_rogoff


m_rogoff wrote:

 

Ultimate goal is 3 lines, outside 2 are layer S-3, middle is layer S-1

 


Perhaps something like this

 

^C^C-layer;_S;S-3;;_line;\\;-layer;_S;S-1;;_OFFSET;_L;_C;;;;.33;@;_M;\\;^C^C_OFFSET;_L;_S;;;

 

Hope that helps

Henrique

 

 

EESignature

Message 7 of 16
hmsilva
in reply to: hmsilva

Or

^C^C-layer;_S;S-3;;_line;\\;-layer;_S;S-1;;_OFFSET;_L;_C;;;;.33;@;_M;\\;^C^C_OFFSET;_L;_S;;;_layerp;_layerp;

 to restore also the current layer

 

Henrique

EESignature

Message 8 of 16
hmsilva
in reply to: hmsilva

Wrong layer order...

^C^C-layer;_S;S-1;;_line;\\;-layer;_S;S-3;;_OFFSET;_L;_C;;;;.33;@;_M;\\;^C^C_OFFSET;_L;_S;;;_layerp;_layerp;

 

Henrique

EESignature

Message 9 of 16
m_rogoff
in reply to: hmsilva

Henrique,

 

  The code was offsetting the middle line on the source layer, so the middle and outside lines were on the same layer. I modified the end to change prop of the last object to the correct layer instead. Thank you for your help, I couldn't have gotten this without your help.

 

 

^C^C-layer;_S;S-3;;_line;\\;-layer;_S;S-1;;_OFFSET;_L;_C;;;;.33;@;_M;\\;^C^C_OFFSET;;;_layerp;_layerp;_Chprop;L;;LA;S-3;;

Message 10 of 16
m_rogoff
in reply to: hmsilva

One more quick question on a very similar macro

 

 

^C^C-layer;_S;S-SHR;;_line;\\;_OFFSET;3;@;\\;^C^C_erase;L;;_layerp;_layerp;;^C^C

 

At the end of the macro, I get a message:

Select object to offset or [Exit/Undo] <Exit>: *Cancel*

I have to manually hit escape to exit out of the command. It also won't delete the first line drawn. Suggestions? Thanks!

Message 11 of 16
hmsilva
in reply to: m_rogoff


@m_rogoff wrote:

Henrique,

 

  The code was offsetting the middle line on the source layer, so the middle and outside lines were on the same layer.


Weird, I have tested the code on AC2012 and AC2014, without any problem.

The las command was '-layerp', if user press enter, will call the last command, and change the last two lines to the source layer.

Do this code work ok on your system?

^C^C-layer;_S;S-1;;_line;\\;-layer;_S;S-3;;_OFFSET​;_L;_C;;;;.33;@;_M;\\;^C^C_layerp;​_layerp;_OFFSET;_L;_S;;;

 

For the other macro, I'll see what I can do... (I don't have AutoCAD on this laptop)

 

Henrique

EESignature

Message 12 of 16
hmsilva
in reply to: m_rogoff


@m_rogoff wrote:

^C^C-layer;_S;S-SHR;;_line;\\;_OFFSET;3;@;\\;^C^C_erase;L;;_layerp;_layerp;;^C^C

 

At the end of the macro, I get a message:

Select object to offset or [Exit/Undo] <Exit>: *Cancel*

I have to manually hit escape to exit out of the command. It also won't delete the first line drawn. Suggestions? Thanks!


Can you explain in words what are you trying to do.

You are setting the layer S-SHR as current, draw a line, offset the line 3 units, pause twice? erase the 'offsetted' line? call 'layerp' command twice? and cancel...

 

Henrique

EESignature

Message 13 of 16
m_rogoff
in reply to: hmsilva

For this routine, I want to draw a line on layer S-SHR, offset 3" (user pick side) then delete the original line. You are left with 1 line, 3" from where it was drawn. I got it to do everything correct but deletes the offset object, not the line drawn. Selecting LAST Object (L) does not work.

 

^C^C-layer;_S;S-SHR;;_line;\\;_OFFSET;3;@;\;_erase;L;;_layerp;;

 

 

Thanks for your help

Message 14 of 16
hmsilva
in reply to: m_rogoff

Try

 

^C^C-layer;_S;S-SHR;;_line;\\;_select;_L;;_OFFSET;3;@;\;_layerp;_.Erase;P;;

 

HTH

Henrique

EESignature

Message 15 of 16
m_rogoff
in reply to: hmsilva

perfect, thanks!!

Message 16 of 16
hmsilva
in reply to: m_rogoff

You're welcome,

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost