TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on July 06, 2021, 08:05:18 AM

Title: Copy - Paste Routine into the command line
Post by: MSTG007 on July 06, 2021, 08:05:18 AM
I know this is an off the wall question. I know some routine commands can be pasted into the command line then hit enter to load.

Example:
Code: [Select]
(defun C:SD () (command "-SCALELISTEDIT" "D" "*" "E"))
Question is, how much code from a routine could i possibly paste to make it run?

Thanks!
Title: Re: Copy - Paste Routine into the command line
Post by: Lonnie on July 06, 2021, 09:40:40 AM
I believe I've done over 100 lines.

I've also done 3 paste from one routine before closing it.
Title: Re: Copy - Paste Routine into the command line
Post by: BIGAL on July 07, 2021, 12:46:55 AM
I write my code and copy and paste and test as I go 100 lines probably, I would suggest though use Notepad++  it has a extension that allows you to run code no need for copy paste.

The only issue with copy paste code is you can not have blank lines, and tabs can do screwy things when copying multiple lines same with comments, hence why you don't see lots of comments in code I post.
Title: Re: Copy - Paste Routine into the command line
Post by: MSTG007 on July 07, 2021, 07:55:59 AM
Just want to be sure... When I copied the routine code and pasted it in, this is what it looked like.

Does it matter if the code would look like this to paste?
Code: [Select]
; This routine runs the code in the active editor of NotePad++ from AutoCAD:
(defun C:n++ nil (C:RunFromNotePadPP)) ; Quick Run
(defun C:RunFromNotePadPP ( / scr *error* err np++ npeditor npSS npMS r )
; NOTE: Requires ActiveX plugin(by David Gausmann) installed on the NP++
; https://sourceforge.net/projects/nppactivexplugin/
(defun *error* (m)
(foreach x (reverse (list np++ npeditor npSS npMS))
(vl-catch-all-apply (function vlax-release-object) (list x))
)
(gc) (gc)
(and msg (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\nError: " msg)))) (princ)
); defun *error*
(setq err
(vl-catch-all-apply
(function
(lambda nil ; THIS WORKS - IT GETS THE ACTIVE DOCUMENT CODE IN NOTEPAD !!!
(setq np++ (vlax-get-or-create-object "NotepadPlusPlus.Application"))
(setq npeditor (vlax-get np++ 'ActiveEditor))
(vlax-invoke-method npeditor 'selectAll)
(setq npSS (vlax-get npeditor 'selections))
(setq npMS (vlax-get npSS 'mainSelection))
(setq r (vlax-get-property npMS 'text))
(vlax-invoke npSS 'setRange 0 0 0 0)
); lambda
); function
); vl-catch-all-apply
); setq err
(*error* nil)(princ)
(if (and r (not (vl-catch-all-error-p err)))
(eval (read (strcat "(list\n" r "\n)")))
)
); defun





Code: [Select]
Base point: (defun C:RunFromNotePadPP ( / scr *error* err np++ npeditor npSS npMS r )
(_>   ; NOTE: Requires ActiveX plugin(by David Gausmann) installed on the NP++
(_>   ; https://sourceforge.net/projects/nppactivexplugin/
(_>
(_>   (defun *error* (m)
((_>     (foreach x (reverse (list np++ npeditor npSS npMS))
(((_>       (vl-catch-all-apply (function vlax-release-object) (list x))
(((_>     )
((_>     (gc) (gc)
((_>     (and msg (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\nError: " msg)))) (princ)
((_>   ); defun *error*
(_>
(_>
(_>   (setq err
((_>     (vl-catch-all-apply
(((_>       (function
((((_>         (lambda nil ; THIS WORKS - IT GETS THE ACTIVE DOCUMENT CODE IN NOTEPAD !!!
(((((_>           (setq np++ (vlax-get-or-create-object "NotepadPlusPlus.Application"))
(((((_>           (setq npeditor (vlax-get np++ 'ActiveEditor))
(((((_>           (vlax-invoke-method npeditor 'selectAll)
(((((_>           (setq npSS (vlax-get npeditor 'selections))
(((((_>           (setq npMS (vlax-get npSS 'mainSelection))
(((((_>           (setq r (vlax-get-property npMS 'text))
(((((_>           (vlax-invoke npSS 'setRange 0 0 0 0)
(((((_>         ); lambda
((((_>       ); function
(((_>     ); vl-catch-all-apply
((_>   ); setq err
(_>
(_>   (*error* nil)(princ)
(_>   (if (and r (not (vl-catch-all-error-p err)))
((_>     (eval (read (strcat "(list\n" r "\n)")))
((_>   )
(_> ); defun
C:RUNFROMNOTEPADPP
Base point:
Title: Re: Copy - Paste Routine into the command line
Post by: Lonnie on July 07, 2021, 11:02:51 AM
It looks like you have a lot of spaces at the end of most of your lines. I find that is a problem.
Title: Re: Copy - Paste Routine into the command line
Post by: BIGAL on July 07, 2021, 10:12:52 PM
Add the notepad extension to your appload startup suite. And yes blank lines on end of lines are interpreted as Enter. With out going into it you can remove spaces off end of lines MS Word is good replace space^p with ^p