line+midpoints = 'fast command'

line+midpoints = 'fast command'

mauro_ribeiroYJWMG
Explorer Explorer
467 Views
4 Replies
Message 1 of 5

line+midpoints = 'fast command'

mauro_ribeiroYJWMG
Explorer
Explorer

Hi,
Can I make some macro or keybord command  (like, if I wrote 'lk') to have a line than CAD ask me to selec to points and the line will be created ate midpoint? I know MTP or Shift thing but I want a short way.
Thanks 

0 Likes
Accepted solutions (1)
468 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

(defun C:LK () (command "_.line" "_m2p" pause pause))

Kent Cooper, AIA
0 Likes
Message 3 of 5

mauro_ribeiroYJWMG
Explorer
Explorer

@Kent1Cooper I'm new at programming CAD. Where i have to put this code? Or I need to save like .lsp?

Ty man 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

You can paste the code right into the Command line, then use the LK command name that it defines.  [Or, it's not necessary to define a command name -- you could just paste in the functional part:

(command "_.line" "_m2p" pause pause)

which will just do it directly.]

 

But you don't want to have to do that every time, or paste in the definition in every drawing where you want to use it.  For wider application, paste it into a plain-text editor such as Notepad, and save it to a file with a .LSP filetype extension.  Use APPLOAD to navigate to it and Load it.  If you want it always available in every drawing, include the code in acaddoc.lsp instead of in a file of its own [my preferred choice of the options described >here< -- there are other approaches].  Or you can do both -- have it defined in a file of its own, and have that file loaded by a (load) function included in acaddoc.lsp.

Kent Cooper, AIA
Message 5 of 5

Sea-Haven
Mentor
Mentor

Something like this maybe.

 

(defun c:mpp ( / obj end start)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick object "))))
(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(setq mp (mapcar '* (mapcar '+ start end) '(0.5 0.5)))
(command-s "line" mp)
)
0 Likes