How ChatGPT explained my Autolisp problem

How ChatGPT explained my Autolisp problem

hencoop
Advisor Advisor
866 Views
2 Replies
Message 1 of 3

How ChatGPT explained my Autolisp problem

hencoop
Advisor
Advisor

As long as it's available, I think I'll be asking ChatGPT my questions first before coming here.  It will even suggest code although it doesn't yet have a full knowledge of the limitations/differences in Autolisp vs LISP and VLX vs ActiveX.  It will suggest alternate code if told of the invalid functions it had used and asked to rewrite it.

I got on this track this morning when I asked ChatGPT to analyze my code and suggest improvements.  It replied that I could improve my code's speed and efficiency by using a dictionary instead of manipulating lists using MAPCAR, ASSOC, and NTH... and it wrote some code examples.  Now, my 'find-nearest-point' function gets applied to an alignment data dictionary and examines each point tuple in the 2588 lisp data items and finds the one closest to a given point.  It returns the result in a small fraction of a second.  The previous list processing method, using the same data set (a list of 2588 lists of 13 items each), takes at least 2 seconds to return the result.  I was stuck trying to understand why I could not use (VLAX-ITEM <dict> <key>)... so I asked ChatGPT.  It gives such informed answers and does so very quickly too!  I've found that the questions must be clear and complete.  Its responses will let me know if my question misses the mark.

 

The 'add' method could not put my data lists because they are too complex.  They don't look it to me but that was ChatGPT's assessment (the error said something about variants...) .  That's why I shifted to 'vlax-ldata-put'.  

Here is a typical data list item '("1" 0.0 442.448 430.951 0.0 0.01 (0 0 0) 8.0 (2 0 0 0) (1.88482e+06 496358.0 0.0) nil 0.0 nil)'  Some of my data lists have been over 4,000 items which begins to slow things down noticably.

 

It seems like ChatGPT may be able to write some flawless code in a high level language like C# in .NET

I'm thinking I can learn to use C# much faster with ChatGPT's help.  I'll explore that more.

Here's my last interaction with ChatGPT:

vlax-ldata-put vs 'add method difference.jpg

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
867 Views
2 Replies
Replies (2)
Message 2 of 3

TerryDotson
Mentor
Mentor
That's why I shifted to 'vlax-ldata-put'.  It seems like ChatGPT may ...

It's short of perfect or it would have warned that in the transition from R14 to 2000 any LDATA stored (in R14) was LOST (attempting to retrieve in 2000).  Hopefully history will never repeat itself on this one.

0 Likes
Message 3 of 3

hencoop
Advisor
Advisor

I have not been using ldata for much.  I make extensive use of LISPINIT=0 and SDI=1 so that all of my lisp data remains intact in a single session's memory as I move from drawing to drawing.  My method for storing my lisp data for the last  30-years has been to write it to a text file.  I use (READ (READ-LINE ...)) on the file to retrieve my data and make it available in the current session.  Writing the data to a text file will continue, but manipulating that data as a list of lists may not continue if putting it in a dictionary as ldata makes it more efficient to retrieve, replace, and use the data... especially on large data sets.  I will need to rewrite lots of code to do that in all my routines.  That fact and that ChatGPT can write good code in multiple languages may help break my dependence upon Autolisp and help me learn and use other more efficient programming languages.  We'll see.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes