How to visual studio code to autolisp

How to visual studio code to autolisp

hanvitstage
Contributor Contributor
1,035 Views
9 Replies
Message 1 of 10

How to visual studio code to autolisp

hanvitstage
Contributor
Contributor

hello!!
I now want to write visualisp code as visual stdio code.
In other words, if you write and run the visual stdio code, autocad will automatically run and the written lisp code will be lode and type c:test() on the command line.
I want to make it work by just entering test.
Please tell me how
I would appreciate it.

hanvitstage@naver.com

0 Likes
1,036 Views
9 Replies
Replies (9)
Message 2 of 10

paullimapa
Mentor
Mentor
0 Likes
Message 3 of 10

hanvitstage
Contributor
Contributor

Thank you.
I don't understand the content well
take a closer look
I will study.
I am a mechanical engineer, but not a programmer.

0 Likes
Message 4 of 10

paullimapa
Mentor
Mentor

Just patiently follow the step by step instructions. If it’s too complicated you can always just use Visual Basic code as is as an editor. Then after you’ve entered the code do a save, drag and drop the saved file onto your AutoCAD drawing area to load it and then enter the newly defined command to see if it works. Another method is to copy and paste each line of code directly onto AutoCADs  command line and you’ll get immediate feedback to see if that works. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 10

MrJSmith
Advocate
Advocate

I am a noob and therefore do all my LISP in Notepad++. I reload the functions with a short function that re-loads all my lisp routines. For example

 

(defun c:hh ()
	(setq path "C:\\LISPs\\") ;Wherever the LISP files are kept that you want to test.
	(foreach file (vl-directory-files path "*.lsp" 1)
		(load (strcat path file))
	)
	(print "Lisps have been reloaded!") (princ)
)

 

In AutoCAD, I'd type "hh " wait for them to finish loading, then type whatever LISP I was testing. Usually that is "test" or whatever.

0 Likes
Message 6 of 10

paullimapa
Mentor
Mentor

I just copy & paste your code into Visual Studio Code and right away you see a number of benefits like how everything is color coded and being able to check for matching parenthesis really help with coding:

paullimapa_0-1703123092764.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 10

MrJSmith
Advocate
Advocate

@paullimapa Yeah, I have NotePad++ do the same thing. It will also give suggestions for functions as you type. VSC does that too with an addon but I also have NotePadd++ doing it with custom made functions including giving information what the function does and what inputs it needs. I was working on trying to get VSC to do the same but I couldn't figure it out and gave up. That was like 2+ years ago though.

 

Unfortunately, highlighting of parentheses only happens when you click on them. But here is an example of it giving info for one of my custom functions along with highlighting.

 

MrJSmith_0-1703200774740.png

 

0 Likes
Message 8 of 10

paullimapa
Mentor
Mentor

So if you're successful in configuring the connection between VSC & AutoCAD to perform the debug feature then that might tilt you over to using VSC instead. But otherwise, just stay with NotePad++ since you're so comfortable with it.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 10

MrJSmith
Advocate
Advocate

@paullimapa Yep. I do think VSC is better but just have not had the time to set it up like my NotePadd++. I was unaware of being able to connect into AutoCAD via it so I'll have to give it another look. Thanks!

Message 10 of 10

Sea-Haven
Mentor
Mentor

Notepad ++ supports run code, you need to download the plugin for Active X, very handy feature. 

SeaHaven_0-1703378187976.png

 

0 Likes