Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Offset Macro

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
BSReyn8
3254 Views, 15 Replies

Offset Macro

Is there a way to make a macro that will offset a line and then change the color of the line that was offset? I do not want to change the layer only the color. I have created one that will offset the line to a different layer but I really need the line to be on the same layer. Using autocad 2012.

 

The purpose of this is that we make parts that need to have a saftey line set back 1.5" from the edge to provide clearance from the tooling and the suction cups that hold the parts. The dxf is then imported into a cam program and it gets a little messy is everything is on different layers. I currently have to offset all my lines and then go back and reselect the offset lines and then change the color.

 

Any help would be greatly appericated

 

 

Thanks

15 REPLIES 15
Message 2 of 16
Charles_Shade
in reply to: BSReyn8

Welcome to the Autodesk Forums!

 

Yes, what can you do from the Command line?

Type out what you want and then convert that to the Macro

 

^C^C_Offset;1.5;\\;_chprop;L;;C;RED;;

Message 3 of 16
BSReyn8
in reply to: BSReyn8

Ok that works great but only for one line and then I have to reslect the command again, hitting enter after the first offset just brings up chprop. Is there a way to make it so that I can contine to select lines to offset until I cancel the comand or at least be able to just hit enter after each offset and it start from the begining again?

 

Thanks

Message 4 of 16
Kent1Cooper
in reply to: BSReyn8


@BSReyn8 wrote:

Ok that works great but only for one line and then I have to reslect the command again, hitting enter after the first offset just brings up chprop. Is there a way to make it so that I can contine to select lines to offset until I cancel the comand or at least be able to just hit enter after each offset and it start from the begining again?

 

Thanks


Precede the double Cancel with an asterisk, and it will automatically repeat as long as you care to keep going:

 

*^C^C_Offset;1.5;\\;_chprop;L;;C;RED;;

Kent Cooper, AIA
Message 5 of 16
m_rogoff
in reply to: Kent1Cooper

I want to do something similar. It would be very helpful if lisp and macro were provided. Thank you very much in advance.

 

 

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

Message 6 of 16
Kent1Cooper
in reply to: m_rogoff


@m_rogoff wrote:

I want to do something similar. It would be very helpful if lisp and macro were provided. Thank you very much in advance.

 

 

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


Here's a quickie, that does things a little differently to reduce the steps slightly [minimally tested]:

 

(defun C:YourCommandName (/ ptA ptB)
  (command "_.line"
    pause ; first point
    (setq ptA (getpoint (getvar 'lastpoint) "\nOther end: "))
    "" ; finish Line
    "_.chprop" (entlast) "" "_layer" "S-3" ""
    "_.offset" 0.66 ptA (setq ptB (getpoint "\nPoint on side to Offset: ")) ""
    "_.offset" 0.33 ptA ptB ""
    "_.chprop" (entlast) "" "_layer" "S-1" ""
  ); command
  (princ)
); defun

 

It assumes the layers already exist.

Kent Cooper, AIA
Message 7 of 16
m_rogoff
in reply to: Kent1Cooper

Thanks Kent, this works well.

 

It looks too complicated for macro (??). The holdup I am having is I can't select "Last" object after running the CHPROP command.

Message 8 of 16
Kent1Cooper
in reply to: m_rogoff


@m_rogoff wrote:

.... 

It looks too complicated for macro (??). The holdup I am having is I can't select "Last" object after running the CHPROP command.


You could have it loaded by acaddoc.lsp or something, and have a macro that just says:

 

^C^CYourCommandName

 

I don't think I understand the issue in your second sentence.  Is it that you're expecting the Last object to be the second outer Line, but it's giving you the inner one [which is actually the Last object in the drawing, given the way the routine works]?  That could be accounted for, I suppose, but the routine works the way it does partly so that one which-side point can be reliably used for both Offsets, which wouldn't be the case if done in your original sequence.  If that's not the issue, and you really can't select something by using the Last option in a select-objects prompt, is there a message?

Kent Cooper, AIA
Message 9 of 16
m_rogoff
in reply to: Kent1Cooper

Unfortunately, some employees are running LT and therefore can't utilize Lisp. Or multiline for that matter.

 

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)

Message 10 of 16
m_rogoff
in reply to: m_rogoff

this works for me

 

 

^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 11 of 16
steve216586
in reply to: m_rogoff

Might MLINE might be a better solution? You are defining the limits of the original line as compared to offsetting an existing line.

"No one can make you feel inferior without your consent. "-Eleanor Roosevelt
Message 12 of 16
m_rogoff
in reply to: steve216586

Mline is not supported in LT.

 

The last macro works as intended. I might consider using a dynamic block instead but personally I prefer just drawing a line and offsetting.

 

Thanks

Message 13 of 16
bbrock5JSWN
in reply to: Kent1Cooper

*^C^C_Offset;1.5;\\;_chprop;L;;C;RED;;

 

what do I change to be able to enter different distances to offset ,  not always 1.5"

Message 14 of 16
sshiotani
in reply to: bbrock5JSWN

^C^C_Offset;\\\;_chprop;L;;C;RED;;

 

 

The slash \  (after Offset)  allows a pause for user input. You will have to hit enter after your input. You can also pick a distance between 2 points. 

Message 15 of 16
Kent1Cooper
in reply to: bbrock5JSWN


@bbrock5JSWN wrote:

*^C^C_Offset;1.5;\\;_chprop;L;;C;RED;;

 

what do I change to be able to enter different distances to offset ,  not always 1.5"


Replace the 1.5 [and its semicolon Enter] with another backslash for User input:

 

*^C^C_Offset;\\\;_chprop;L;;C;RED;;

Kent Cooper, AIA
Message 16 of 16

I have note done macros in autocad before. Wondering if it would be possible to offset a line twice, to two different distances and layers. I.E. click once and offset a line 6" to lay1 and another line 3" to lay2. Thanks for any input!

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

Post to forums  

Autodesk Design & Make Report

”Boost