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

Multiple offset distance settings?

27 REPLIES 27
Reply
Message 1 of 28
Anonymous
887 Views, 27 Replies

Multiple offset distance settings?

Is there a lisp routine that can retain multiple offset distances?

Example: have the offset command have multiple start commands: O1, O2, O3,
O4

When you type O1 it prompts (command prompt) you for a offset distance or
return to except the current default in brackets.
When you type O2 it prompts (command prompt) you for a offset distance or
return to except the current default in brackets.
etc.

Many times I have need to offset things say 2 3/4" and others 1 1/2"
....sometimes toggling back and forth but keying in the new distance each
time it changes.

Thanks
27 REPLIES 27
Message 21 of 28
Anonymous
in reply to: Anonymous

1) Is the name of the function, followed by a space, then is apostrophe
preceding the variable name

(vl-bb-set 'variable_name value)
(vl-bb-ref ''variable_name)

2) Very well seen, it should be (command "OFFSET" (vl-bb-ref 'ofsdistA)).

Constantin


"Kent Cooper" a écrit dans le message de
news: 5333187@discussion.autodesk.com...
I'm trying out this approach, too. Two questions:

Syntax question -- does the apostrophe really go immediately after
vl-bb-ref, with the space after the apostrophe, or should it be the way you
used vl-bb-set and vl-propagate, where the vl- term is followed by a space,
and the apostrophe precedes the variable name?

And, should I also replace the last function
(command "OFFSET" ofsdistA)
with
(command "OFFSET" (vl-bb-ref 'ofsdistA))
since I don't have a variable ofsdistA within the current drawing, or will
vl-bb-set create that at the same time?

Thanks again,
--
Kent Cooper


"Constantin" wrote...
In the other proposed way, the number of code lines remain the same, the
variables name remain the same, the only changes are:

(cond (ofsdistA (setq ofsdistprompt (rtos ofsdistA 4 4)))

becomes

(cond ((vl-bb-ref ' ofsdistA)(setq ofsdistprompt (rtos (vl-bb-ref '
ofsdistA) 4 4)))

and

(if ofsdistA1 (setq ofsdistA ofsdistA1))

becomes

(if ofsdistA1 (vl-bb-set 'ofsdistA ofsdistA1))

Constantin
Message 22 of 28
Anonymous
in reply to: Anonymous

I'm sorry, is not

(vl-bb-ref ''variable_name)

but

(vl-bb-ref 'variable_name)

is about an apostrphe.

Constantin

"Constantin" a écrit dans le message de
news: 5333167@discussion.autodesk.com...
1) Is the name of the function, followed by a space, then is apostrophe
preceding the variable name

(vl-bb-set 'variable_name value)
(vl-bb-ref ''variable_name)

2) Very well seen, it should be (command "OFFSET" (vl-bb-ref 'ofsdistA)).

Constantin


"Kent Cooper" a écrit dans le message de
news: 5333187@discussion.autodesk.com...
I'm trying out this approach, too. Two questions:

Syntax question -- does the apostrophe really go immediately after
vl-bb-ref, with the space after the apostrophe, or should it be the way you
used vl-bb-set and vl-propagate, where the vl- term is followed by a space,
and the apostrophe precedes the variable name?

And, should I also replace the last function
(command "OFFSET" ofsdistA)
with
(command "OFFSET" (vl-bb-ref 'ofsdistA))
since I don't have a variable ofsdistA within the current drawing, or will
vl-bb-set create that at the same time?

Thanks again,
--
Kent Cooper


"Constantin" wrote...
In the other proposed way, the number of code lines remain the same, the
variables name remain the same, the only changes are:

(cond (ofsdistA (setq ofsdistprompt (rtos ofsdistA 4 4)))

becomes

(cond ((vl-bb-ref ' ofsdistA)(setq ofsdistprompt (rtos (vl-bb-ref '
ofsdistA) 4 4)))

and

(if ofsdistA1 (setq ofsdistA ofsdistA1))

becomes

(if ofsdistA1 (vl-bb-set 'ofsdistA ofsdistA1))

Constantin
Message 23 of 28
Anonymous
in reply to: Anonymous

I assumed as much from the other examples. Thank you again for your help.
--
Kent Cooper


"Constantin" wrote...
I'm sorry, is not

(vl-bb-ref ''variable_name)

but

(vl-bb-ref 'variable_name)

is about an apostrphe.

Constantin

....
Message 24 of 28
Anonymous
in reply to: Anonymous

> (vl-bb-ref ''variable_name)


It works with strings too.....

(vl-bb-set "my_symbol" "the_value_as_string") ;; or any other lisp data
value.
(vl-bb-ref "my_symbol")
Message 25 of 28
Anonymous
in reply to: Anonymous

Mmm,

I didn't know this. Thanks Louis.

Constantin

"Luis Esquivel" a écrit dans le message de news:
5333205@discussion.autodesk.com...
> (vl-bb-ref ''variable_name)


It works with strings too.....

(vl-bb-set "my_symbol" "the_value_as_string") ;; or any other lisp data
value.
(vl-bb-ref "my_symbol")
Message 26 of 28
Anonymous
in reply to: Anonymous

Here are two "finished" routines I have put together, with very helpful
contributions from Tim and Constantin. One (OFFMULTp) uses the vl-propagate
approach, and the other (OFFMULTb) uses the vl-bb- approach. I've decided
to use the latter, just because it doesn't stick those variable values into
a drawing unless they're called for, but they both function the same for the
user.

You just type OA, and if there's no value set, it offers the current offset
distance as a default, but if it's been used earlier in this AutoCAD
session, it offers that previously-set value. The same for OB, OC, OD, and
OE. It keeps separate values for each, so every time you call one up, you
can just accept its default value, and switch among them freely without
having to enter values each time, and those values carry over into other
drawings. If you have it set up to load automatically with each drawing
opened, all you need is to type the OA, OB, etc. Otherwise, you need to
(appload) one of them in a drawing in which you want to use it.

Others may want to change the mode and precision in the (rtos) functions to
match their needs.

Thanks to Constantin and Tim, and to ADK for raising the question in the
first place.

--
Kent Cooper


"ADK" wrote...
Is there a lisp routine that can retain multiple offset distances?

Example: have the offset command have multiple start commands: O1, O2, O3,
O4

When you type O1 it prompts (command prompt) you for a offset distance or
return to except the current default in brackets.
When you type O2 it prompts (command prompt) you for a offset distance or
return to except the current default in brackets.
etc.

Many times I have need to offset things say 2 3/4" and others 1 1/2"
....sometimes toggling back and forth but keying in the new distance each
time it changes.

Thanks
Message 27 of 28
Kent1Cooper
in reply to: Anonymous

I have improved on and expanded my earlier multiple-saved-Offset-values routine.

 

The attached version uses Environment Variables instead of either (vl-propagate) or (vl-bb-...) functions, which has the advantage that the values are retained, and are not only available across all drawings, but remain available even after getting out of AutoCAD, shutting down, etc.  It otherwise works the same way for the User as the previous version.

 

It consolidates its main workings into one sub-routine, with each command name just calling that up with its own suffix after the "O" as an argument.  And because it was therefore very easy to do, it has many more commands available [20, with number suffixes, O0 through O9, and letters, OA through OJ].  It could easily be expanded for more if needed -- I stopped there partly just because I already have a command OL [= Offset to another Layer] defined.  Others may have some of these command names in use already, so they would need to remove them from this, or rename these somehow, or something.

 

I have this:

 

(autoload "OffMult" '("O0" "O1" "O2" "O3" "O4" "O5" "O6" "O7" "O8" "O8" "OA" "OB" "OC" "OD" "OE" "OF" "OG" "OH" "OI" "OJ"))
 

in acaddoc.lsp, so the commands are available in all drawings, but the file isn't loaded until the User calls for one of the commands.

Kent Cooper, AIA
Message 28 of 28
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

I have improved on and expanded my earlier multiple-saved-Offset-values routine.

....


And then, I thought of a further refinement that seemed worth incorporating.  The version attached here retains ordinary Offset's default distance despite the use of these commands.  So in effect, ordinary Offset becomes a twenty-first "slot" that remembers its own setting separately from the others [except that unlike the others, its default value will not be shared across drawings, nor survive getting out of AutoCAD].

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost