Jump to content

AUTOCAD Customization - which language to learn?


Vittorio

Recommended Posts

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 

Link to comment
Share on other sites

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 by mhupp
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

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 by marko_ribar
  • Like 2
  • Thanks 2
Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

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?? 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Danielm103
content
  • Thanks 1
Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...