Jump to content

Recommended Posts

Posted (edited)

I got this code from chatgpt, that chatgpt got from a defunct post from autocad website forums. Whenever I tried going to the website or googling, the link seems broken so I don't know how this code exactly works.

 

I am trying to make a Lisp that creates dimstyles from scratch. everything is working except for changing between annotative and non annotative. The code below does a good job of setting the created dimension style to annotative. But when I ask chat gpt to make it in reverse, i.e. make a code that makes the created dimstyle non annotative, it can't.
 

(defun set-dimstyle-annotative (dimstyle-name / ent entdata xdata)
  ;; Ensure the dimension style exists
  (if (and (setq ent (tblobjname "dimstyle" dimstyle-name))
           (setq entdata (entget ent)))
    (progn
      ;; Check if XData for "AcadAnnotative" exists
      (if (not (assoc -3 entdata))
        (progn
          ;; Add XData to set the dimension style as annotative
          (setq xdata
                '((-3
                   ("AcadAnnotative"
                    (1000 . "AnnotativeData")
                    (1002 . "{")
                    (1070 . 1)  ; Version number
                    (1070 . 1)  ; Annotative flag: 1 = Yes, 0 = No
                    (1002 . "}")
                   )
                  )
                 )
                )
          ;; Apply the XData to the dimension style
          (entmod (append entdata xdata))
          (princ (strcat "\nDimension style '" dimstyle-name "' set to annotative."))
        )
        (princ (strcat "\nDimension style '" dimstyle-name "' is already annotative."))
      )
    )
    (princ (strcat "\nDimension style '" dimstyle-name "' not found."))
  )
  (princ)
)



Basically when a dimstyle is created, I put this at the end of the code to make it annotative. However, after making an annotative dimstyle, I can make a dimstyle, but because the previous was annotative, I cannot set the new dimstyle to non annotative. Chat gpt gave me a code but it seems it just butchered the code and it doesn't work.

 

I attached the lisp file. Thanks!!

 

DimStyles.lsp

Edited by SLW210
Added Code Tags!

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