Vittorio Posted November 1, 2021 Posted November 1, 2021 Hi everybody, I am new to AutoCAD programming and would like to start learning, but there are different languages and I just don't know where to start. AutoLISP, VisualLISP, VBA? I already know JavaScript, VBA, Java and a little Batch and AutoCAD scripting. Where should my journey start? My first project should deal with coordinates (coordinate text file import to COGO points, etc). Hoping to get some information here. Many thanks in advance Vittorio Quote
mhupp Posted November 1, 2021 Posted November 1, 2021 (edited) Fist off Welcome to the forums. Depends on what you prefer. Even tho I have programmed in VBA for excel i stick to autolisp and Visual lisp for CAD. 1. not many people code in VBA macros so getting help might be a problem. 2. most people code in in lisp or vlisp for CAD. & i think its a little more intuitive. 3. vlisp and autolisp can be used at the same time. cant mix vba and lisp code. Here are some websites I recommend. http://www.lee-mac.com/tutorials.html https://www.afralisp.net/ https://jtbworld.com/autolisp-visual-lisp http://www.cadtutor.net/tutorials/autolisp/quick-start.php? Here are a few lisp to help out. these dump all the visual lisp and dxf properties of selected objects. ;;----------------------------------------------------------------------------;; ;; Dump All Visual lisp properties for selected objects (defun C:VDumpit (/ SS ent) (vl-load-com) (if (setq SS (ssget)) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t) ) ) (textscr) (princ) ) ;;----------------------------------------------------------------------------;; ;; Dump all DXF Group Data (defun c:DumpIt (/ SS ent) (if (setq SS (ssget)) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (mapcar 'print (entget ent '( "*"))) ) ) (textscr) (princ) ) Edited November 2, 2021 by mhupp 1 2 Quote
marko_ribar Posted November 1, 2021 Posted November 1, 2021 (edited) mhupp, Just for your better usage of first example, consider adding t argument here : (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t) It will show methods supported by VLA-OBJECT besides all available properties... It can be useful... Edited November 1, 2021 by marko_ribar 2 2 Quote
BIGAL Posted November 1, 2021 Posted November 1, 2021 Mhupp cant mix vba and lisp code. You can call VBA code from lisp. (defun C:dtop () (vl-vbaload "P:/AutoDESK/VBA/filecopy.dvb") (vl-vbarun "filecopy") ) Quote
mhupp Posted November 2, 2021 Posted November 2, 2021 What I meant was you can use vlisp and autolisp in the same lisp file. where as VBA code would require its own separate file. Quote
mhupp Posted November 2, 2021 Posted November 2, 2021 47 minutes ago, SLW210 said: .NET is also an Option. and python Quote
Mugna101 Posted November 2, 2021 Posted November 2, 2021 5 minutes ago, mhupp said: and python how can i use python for AutoCAD? is there a package or something? Quote
mhupp Posted November 2, 2021 Posted November 2, 2021 (edited) https://pypi.org/project/pyautocad/ https://ironpython.net/ Edited November 2, 2021 by mhupp Quote
tombu Posted November 2, 2021 Posted November 2, 2021 https://www.autodesk.com/autodesk-university/class/Getting-Started-Python-2019 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/python-programming-in-autocad/td-p/8164948 1 Quote
Vittorio Posted November 2, 2021 Author Posted November 2, 2021 Holy ... So there are really a lot of options. I think I'll stick with LISP, as there's much more stuff out there dealing with AutoLISP / VisualLISP than the other languages. Could anybody sum up the main difference between AutoLISP and VisualLISP in one sentence? What would you recommend me to do first? Reading one of the above mentioned tutorials would be my first thought. And which one should I choose, AutoLISP or VisualLISP and which Editor / IDE is best for learning? Lee Mac suggested VLIDE and that would also be my choice. For example, when coding VBA (for Excel) I use the plain built-in VBA Editor and when I need to know more I just google it and move the browser to my second monitor or when coding JavaScript I use Notepad++, since I know most of the functions. Does anyone know some good resources for learning, I am thinking of lessons with examples. Quote
BIGAL Posted November 2, 2021 Posted November 2, 2021 Stepping outside of Vlide use Notepad++ that is correct name, it has a lisp format built in which is very handy shows bracket matches, great for debugging as you write. Re lisp or visualLisp for me 40 years, VL has advantage at times of using readable properties (Vla-get-layer obj v's (cdr (assoc 8 obj sometimes solutions are more directly enabled using entnext and the dxf codes. If you thinking linking to Excel or Word or Access then VL is the way to go Autocad can talk to them. Last post else where was get range selected in excel. The where do I get resources has been asked before many times lots of links. Books look at Kindle, Togores, Reinaldo N. very cheap 4 books. Afralisp has tutorials. The Visual lisp developers bible.pdf Others will jump in. 1 Quote
Mostafa hisham Posted December 2, 2023 Posted December 2, 2023 I know some of python language can i depend on that to make prgramming in autocad? How is the powerful of this language and pyautocad library in prgramming in autocad?? Quote
Steven P Posted December 2, 2023 Posted December 2, 2023 I've not been convinced with Python yet, LISP is OK since a lot of the commands relate to the commands you use in AutoCAD so is an easy conversion from using the software to programming for it. If you look at this forum most of the programming questions are LISP Quote
Danielm103 Posted December 3, 2023 Posted December 3, 2023 (edited) check out my project, Python for AutoCAD https://github.com/CEXT-Dan/PyRx wrapping Python around ARX. Python is pretty awesome with because of it's libraries. GIS stuff i.e. shapely / geopandas https://pyarx.blogspot.com/search/label/geopandas pandas is totally amazing for data extraction, I have a couple samples here https://pyarx.blogspot.com/2023/11/pandas-for-data-extraction-merging.html adding charts and doing data analysis https://pyarx.blogspot.com/2023/11/generate-plot-chart-from-autocad-table.html Edited December 3, 2023 by Danielm103 content 1 Quote
Danielm103 Posted December 3, 2023 Posted December 3, 2023 13 hours ago, Mostafa hisham said: I know some of python language can i depend on that to make prgramming in autocad? How is the powerful of this language and pyautocad library in prgramming in autocad?? Pyautocad works, but its out of process so it’s very slow. However it’s good enough to tinker with Pyautocad uses ActiveX, which is powerful enough https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-A809CD71-4655-44E2-B674-1FE200B9FE30 You actually don’t need Pyautocad, you can generate early binding wrappers for AutoCAD using win32com’s makepy But Pyautocad has handy utilities, so it’s probably best to start with that 1 Quote
SLW210 Posted December 4, 2023 Posted December 4, 2023 Also as mentioned previously, IronPython as well for AutoCAD, not just Pyautocad. Lots of options to use Python for AutoCAD. You might look at CadPythonShell as well as what Danielm103 has supplied. IMO, it depends on what you want to accomplish as well as what you have current experience with as to which programming language you want to use/learn. Thanks for all of those links Danielm103! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.