Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Multipe offset button

kina_86
Contributor

Multipe offset button

kina_86
Contributor
Contributor

Hello!
First of all, i want to creeat a button who can offset a polyline (selected by user) one the left side (10,20) and the same on the right side.
I try "^C^C_OFFSET;;\;Multiple;;20;" but is something wrong about defining the side and i don 'know how to do this ...

kina_waly_0-1629388380309.png

This is what i want, but first i need to manage this problem...

kina_waly_1-1629388983450.png

 

 

0 Me gusta
Responder
Soluciones aceptadas (4)
718 Vistas
11 Respuestas
Respuestas (11)

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

is that what you are looking for?

^C^C_OFFSET;20;\_MULTIPLE;

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2025
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Me gusta

Kent1Cooper
Consultant
Consultant

@kina_86 wrote:

.... i want to creeat a button who can offset a polyline (selected by user) one the left side (10,20) and the same on the right side.
....


Will >this< do it for you?  [Not if you use LT.  If you don't, you could have OffsetBothSides.lsp loaded automatically, and your button could contain just its OBS command name.]

Kent Cooper, AIA

kina_86
Contributor
Contributor

This macro work for multiple offsets with 20(only), i want to run command offset, select one single time my polyline and after that to do automaticaly offsets (10;20;-10;-20) without any selection of side, or distance...

Maybe this video make you to see what i want to do (of course without fillet and text).

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/screencast/Main/Details/4cc12a75-d...

0 Me gusta

ВeekeeCZ
Consultant
Consultant

Perhaps like this?

 

^C^C_OFFSET;10;\_MULTIPLE;\@;\@;;;

 

Select your polyline, pick one side far enough, then the other side.

0 Me gusta

Kent1Cooper
Consultant
Consultant
Solución aceptada

@kina_86 wrote:

.... i want to run command offset, select one single time my polyline and after that to do automaticaly offsets (10;20;-10;-20) without any selection of side, or distance. .....

 


A modification and simplification of my earlier linked routine:

;;  OffsetBothSides1020.lsp [command name: OBS1020]
;;  To Offset the same object to Both Sides at both 10 & 20 units.
;;  Kent Cooper, 19 August 2021
(defun C:OBS1020 (/ obj); = Offset to Both Sides 10 & 20 units
  (while (setq ent (car (entsel "\nSelect object to Offset to Both Sides [Esc to exit]: ")))
    (setq obj (vlax-ename->vla-object ent))
    (vla-offset obj 10)
    (vla-offset obj 20)
    (vla-offset obj -10)
    (vla-offset obj -20)
  ); end while
  (princ)
); defun
(prompt "Type OBS1020 to Offset to Both Sides by 10 & 20 units.")

It could be expanded to put the results on different Layers, to verify that you picked the right kind of thing, to ask again if you miss, to wrap the whole in Undo begin/end, and all the other usual enhancements.

Kent Cooper, AIA
0 Me gusta

kina_86
Contributor
Contributor

I would like to be without a lisp, but is ok... Now i set my botton to automatically load this lisp.

0 Me gusta

Kent1Cooper
Consultant
Consultant
Solución aceptada

@kina_86 wrote:

I would like to be without a lisp, but is ok... Now i set my botton to automatically load this lisp.


With a pure non-AutoLisp macro, you described the problem from the start -- defining the side to Offset to in a way that's guaranteed to get you the desired sides in all conditions.

 

If the idea is that you want to be able to use a Tool Palette button but not have to load an external file to define a command, and not that you have any objection to AutoLisp code being used in the button macro, you can do this:

 

*^C^C(setq ent (car (entsel "Pick: "))) \(foreach d '(10 20 -10 -20) (vla-offset (vlax-ename->vla-object ent) d))

or

(while (setq ent (car (entsel "Pick: "))) (foreach d '(10 20 -10 -20) (vla-offset (vlax-ename->vla-object ent) d)))

 

Not all AutoLisp functions can be used in command macros, but enough of them work to do that.  You can expand on the prompt part if you like.

 

Both worked for me in limited testing -- they just have different ways of repeating automatically.  It doesn't seem possible to suppress the (setq) function at the command line [yes, I tried the ^P thing], which is a visual disadvantage over the command-definition approach.  [I prefer the first one, which ends more cleanly with Escape.]

Kent Cooper, AIA

ВeekeeCZ
Consultant
Consultant
Solución aceptada

Or this way.

 

^C^C^P((lambda (/ o d) (vl-load-com) (while (setq o (car (entsel))) (setq o (vlax-ename->vla-object o)) (foreach d '(-20 -10 10 20) (vla-offset o d)) (princ))))

kina_86
Contributor
Contributor

Thank you both, one last question where i can find more information about this "coding language"?

0 Me gusta

Kent1Cooper
Consultant
Consultant

@kina_86 wrote:

Thank you both, one last question where i can find more information about this "coding language"?


Search the >Customization Forum< for terms like "learn AutoLisp" [or with just "Lisp", since a lot of people refer to it that way] and "Lisp tutorials" and similar wordings.  And there's an entire >AutoLisp Reference< in which you can look up functions and see what arguments they take, what they return, etc.

Kent Cooper, AIA

ВeekeeCZ
Consultant
Consultant
Solución aceptada

Version with layers.

((lambda (/ o d l) (vl-load-com) (setq l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (while (setq o (car (entsel))) (setq o (vlax-ename->vla-object o)) (foreach d '((-20 . "Layer1") (-10 . "Layer2") (10 . "Layer2") (20 . "Layer1")) (vla-add l (cdr d)) (vla-put-layer (car (vlax-invoke o 'Offset (car d))) (cdr d))) (princ))))