Talking to AI about a Lisp

pic19.png

The future is bright but also ensures change. In recent years the buzzword "disruption" has been ubiquitous. Especially when it comes to things like Artificial Intelligence (AI) or Machine Learning. I naturally get excited about these promising technologies as they are described in science-fiction-like optimism. Often my excitement comes long before the technology itself hits the Plateau of Productivity on the Gartner Hype Cycle.  The problem with that is I spend a lot of time in the "Trough of disillusionment." So when I heard about the really cool things happening with ChatGPT AI, I was naturally skeptical... or more correctly, I didn't want to fall in love only to be thrown back into the trough. 

 

There have been some really interesting things happening lately and we may be really close to realizing some fantastic and intelligent tools. Things like the AutoCAD My Insights Macro Advisor which takes advantage of machine learning and your individual usage data have already done some wonderful things for me. It really feels like we have at least opened the door to the Plateau of Productivity. 

 

There is a lot of buzz about ChatGPT (including some excitement from the illustrious Shaan Hurley's Twitter Feed). Ultimately when I heard about some amazing poetic feats of this technology in a nontechnical podcast, it was apparent how universal and wide spread the impact and 'wow' of this technology had reached. With that, it might be time for me to try to love again. So I went and signed up for https://chat.openai.com/chat and struck up a conversation with AI.

 

Before I get into the dialog, I must give context and manage expectations. The technology is still in testing and development per the site, yet it is still extremally promising and impressive. That said it is not at a point where I'm polishing my resume. The AI is able to solve logical problems and frame the solutions in several formats. It was not purpose built for anything I ask of it.  Another thing to remember is that this is not an Autodesk product and was not built specific to the purposes of AutoCAD. All applications I have seen thus far have not been geared towards creating visual representations, so my ask is outside everything I've seen it do well. 

 

I started with a 'simple' request: "I need a lisp for AutoCAD that draws the Autodesk Logo."

 

TheCADnoob_0-1672855197396.png

 

Much like C-3P0 and his refrain "I am C-3PO, human-cyborg relations." the AI has some explanatory notes about what its doing but soon spits out some code. This is followed by an explanation on how to use it. 

 

 

 

 

 

 

 

 

 

 

 

(defun c:autodesk ()
  (setq a (cons 0 0) b (cons 4 0) c (cons 4 2) d (cons 0 2) e (cons 2 1))
  (command "pline" a b c d e a "")
  (setq f (cons 2.6 0.4) g (cons 3.4 0.4) h (cons 3.4 1.6) i (cons 2.6 1.6) j (cons 3 1))
  (command "pline" f g h i j f "")
  (setq k (cons -0.5 0) l (cons -0.5 2) m (cons 4.5 2) n (cons 4.5 0))
  (command "box" k l m n "")
  (setq o (cons -1 0) p (cons -1 2) q (cons 5 2) r (cons 5 0))
  (command "box" o p q r ""))

 

 

 

 

 

 

 

 

 

 

 

The code of course didn't work. Interestingly enough when you inform the AI about this it has some troubleshooting suggestions. 

 

"I apologize that the revised LISP function is not working for you. Here are a few things you can try to troubleshoot the issue:

  • Make sure you are typing the function name correctly. It should be "autodesk" (without the quotes).
  • Make sure you are typing the function name into the command line and not the command window.
  • Make sure you are pressing Enter after typing the function name.
  • Make sure you have closed all open command prompts before running the function.

If you have checked all of these things and the function is still not working, there may be an issue with the function itself. One thing you can try is to copy and paste the function into a new file and save it with a .lsp extension. Then load the file into AutoCAD using the (load) function. This will allow you to see any error messages that may be generated when the function is run.

I apologize for any inconvenience this may have caused. Please let me know if you have any other questions or if there is anything else I can help with."

 

At this point I decided to simplify the request as I figured it may not have been as simple a request as I originally thought.

 

TheCADnoob_1-1672855323213.png

 

Again this code did not work. I asked if the AI actually knew the lisp programming language and it basically informed me that it didn't know any programming language but knew about them and their syntax.  Knowing this I was able to offer suggestions that might help make the code work. 

 

I'm not a huge fan of the lisp language (call it a foible of mine) so for the lisp veterans out there this may have been a quick fix, but for me, it took a little bit to figure out why it was failing. In this case the code was just not giving the proper inputs to complete the command. After I explained that there were some missing elements the AI rewrote the code and after a few iterations we got the following:

 

 

 

 

 

 

 

 

 

 

(defun c:autodesk ()
  (setq text "Autodesk"
        pt "0,0"
        height 1
        rotation 0)
  (command "text" pt height rotation text "")
  (princ))

 

 

 

 

 

 

 

 

 

 

 

Voila the code was successful!

 

TheCADnoob_3-1672855429729.png

 

So one of the key take aways from the troubleshooting this code was the way that the AI was sending coordinates and input to the command line. The method it was using originally didn't work, but after figuring that out, it was time to apply that solution to the code of my original request; the Autodesk logo. This time it worked. The AI took what we discussed from the successful code and applied it to the code from my original request.

 

TheCADnoob_4-1672855478593.png

 

 

 

 

 

 

 

 

 

 

(defun c:autodesk ()
  (setq a "0,0"
        b "4,0"
        c "4,2"
        d "0,2"
        e "2,1")
  (command "pline" a b c d e a "")
  (setq f "2.6,0.4"
        g "3.4,0.4"
        h "3.4,1.6"
        i "2.6,1.6"
        j "3,1")
  (command "pline" f g h i j f "")
  (setq k "-0.5,0"
        l "-0.5,2"
        m "4.5,2"
        n "4.5,0")
  (command "box" k l m n "")
  (setq o "-1,0"
        p "-1,2"
        q "5,2"
        r "5,0")
  (command "box" o p q r ""))

 

 

 

 

 

 

 

 

 

Amazingly it worked! But it obviously didn't quite have a clear idea of what I was asking for. 

 

TheCADnoob_0-1672856514715.png

 

(unless it was referencing some older logos but perhaps I'm reaching)

 

TheCADnoob_1-1673016232236.png

 

I let it know that wasnt the logo I was looking for. 

 

TheCADnoob_6-1672855556908.png

 

Seeing that it might need some help on the visuals I asked if I could better define the picture but unfortunately the only medium for visual communication is ACII art. So I did my best... and so did the AI. 

 

 

 

 

 

 

 

 

 

                      'coooooooooooc.   
                  ,ldkNMMMMMMMMMMMMK,   
              .,oONMMMMMMMMMMMMMMMMK,   
           .;d0WMMMMMMMMMMMMMMMMMMMK,   
        .cxKWMMMMMMMMMMWWNNNNNNNNNWK,   
     'ckXMMMMMMMMMMWNKx:'''''''',c0K,   
   .xNMMMMMMMMMMW0d;'.        'cxXWK,   
   ,KMMMMMMMMNOo,.        .,oONMMMMK,   
   ,0MMMMMXkl'          'd0WMMMMMMMK,   
   ,0MWXxc.            .xMMMMMMMMMMK,   
   'xd:.               .dNNNNNNNNNNO'   
                        ............    

 

 

 

 

 

 

 

 

 

 

 

TheCADnoob_8-1672855646080.png

 

 

 

 

 

 

 

 

 

 

 

 

(defun c:autodesk ()
  (setq a "0,0"
        b "5,0"
        c "5,1"
        d "4,1"
        e "4,2"
        f "1,2"
        g "1,1"
        h "0,1")
  (command "pline" a b c d e f g h a "")
  (setq i "3,0"
        j "3,1")
  (command "pline" i j "")
  (setq k "-1,0"
        l "-1,2"
        m "6,2"
        n "6,0")
  (command "box" k l m n ""))

 

 

 

 

 

 

 

 

 

 

 

 

 

At first glance, it was clear that my job was safe for now. This AI is not going to take my place in the drafting world soon. But on closer inspection, it's actually not bad considering that this AI is not for drafting and it was going off and ASCII interpretation of the image. Also if you consider that the box surrounding the image is likely vestigial in the AI's understanding of what an image is. In other words it may think it needs a box around images. I could see how the image could be a primitive representation of a badly pixelated image. Imagine trying to draw the Autodesk logo with only 8 pixels or so and this might be a decent approximation.  

 

TheCADnoob_7-1672855626994.png

 

TheCADnoob_9-1672855748804.png

 

Overall I'm pretty impressed. I'm not sure this technology is going to take my drafting job yet, but I can definitely see it being an absolute asset for my productivity. When I do code in lisp its usually a lot of cut and paste and if I started my coding journey here, this could likely give me a tailored framework to start my cut and paste journey. 

 

I think in my next attempt I'm going to ask for an algorithm for coding as opposed to the code its self and see how it goes from there. On to the Plateau of Productivity!

 

 

4 Comments