Author Topic: extended data routine :: beta testers wanted  (Read 8054 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« on: May 04, 2004, 01:44:38 PM »
please do NOT run this on a production dwg and thanks for any feedback.
Code: [Select]

;;; read and write extended entity data
;;; adds a user note to an entity and date stamp
;;; version 0.1 Tue May 04, 2004
(defun idate () (atoi (rtos (getvar 'cdate) 2 0)))
 
(defun make-lst (xname note)
  (list
    (list -3
          (list xname (cons 1000 note) (cons 1040 (idate))))
    )
  )

(defun chk-for (xapp ent)
  (assoc 1000 (cdr (cadr (assoc -3 (entget ent (list xapp))))))
  )

(defun set-xdata (/ xapp ent kwd note new_ent)
  (setq xapp "user_xnote")


  (if (setq ent (car (entsel "\nSelect entity: ")))
    (if (chk-for xapp ent)
      (progn
        (initget 1 "Yes No")
        (setq
          kwd (getkword
                "\nEntity has note attached, overwrite? (Y/N): "
                )
          )
        (if (= kwd "Yes")
          (setq note (getstring T "\nEnter note: "))
          )
        )
      (setq note (getstring T "\nEnter note: "))
      )
    )

  (if (and note (/= note ""))
    (progn
      (setq new_ent
            (append (entget ent) (make-lst xapp note))
            )
      (entmod new_ent)
      )
    )
  (princ)
  )

(defun read-xdata (/ xapp ent xd)
  (setq xapp "user_xnote")
  (regapp xapp)

  (if (setq ent (car (entsel "\nSelect entity: ")))
    (setq xd (assoc -3 (entget ent (list xapp))))
    )

  (if xd
    (princ
      (strcat
        "\nNote: "
        (cdr (assoc 1000 (cdr (cadr xd))))
        "\nDate : "
        (rtos (cdr (assoc 1040 (cdr (cadr xd)))) 2 0)
        )
      )
    )
  (princ)
  )

(defun c:xNotes (/ kwd)
  (regapp "user_xnote")
  (initget "Add Read")
  (setq kwd
        (getkword "\nDo you want to Add or Read notes? (A/R) <Add>: ")
        )
  (cond ((or (= kwd nil)(= kwd "Add"))
         (set-xdata))
        ((= kwd "Read")
         (read-xdata))
        )
  )
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
extended data routine :: beta testers wanted
« Reply #1 on: May 04, 2004, 05:36:44 PM »
Dont have time to crash test it Mark :) but I'm sure you have done that already.

suggestion :
A Text file of default notes read into a list dialog works for me in a similar situation .. ensures consistancy, and saves spelling mistakes.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« Reply #2 on: May 04, 2004, 05:46:11 PM »
Quote from: Kerry Brown
suggestion :
A Text file of default notes read into a list dialog works for me in a similar situation .. ensures consistancy, and saves spelling mistakes.

excellent idea, thanks Kerry
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
extended data routine :: beta testers wanted
« Reply #3 on: May 04, 2004, 05:51:51 PM »
yep, its critical for me 'cause I have a habit of not ensuring my brain and fingers are fully co-ordinated.
.. particularly important as the text value is not available for visible confirmation.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

SMadsen

  • Guest
extended data routine :: beta testers wanted
« Reply #4 on: May 05, 2004, 04:41:34 AM »
Works like a charm, Mark. Don't have any comments, except maybe that it's a bit unclear what happens when the user chooses to overwrite the xdata and makes an empty response.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« Reply #5 on: May 05, 2004, 07:01:26 AM »
Thanks Stig.
new version:
Code: [Select]

;;; read and write extended entity data
;;; adds a user note to an entity and date stamp
;;; version 0.2 Wed May 05, 2004
(defun idate () (atoi (rtos (getvar 'cdate) 2 0)))
 
(defun make-lst (xname note)
  (list
    (list -3
          (list xname (cons 1000 note) (cons 1040 (idate))))
    )
  )

(defun chk-for (xapp ent)
  (assoc 1000 (cdr (cadr (assoc -3 (entget ent (list xapp))))))
  )

(defun set-xdata (/ xapp ent kwd note new_ent)
  (setq xapp "user_xnote")


  (if (setq ent (car (entsel "\nSelect entity: ")))
    (if (chk-for xapp ent)
      (progn
        (initget 1 "Yes No")
        (setq
          kwd (getkword
                "\nEntity has note attached, overwrite? (Y/N): "
                )
          )
        (if (= kwd "Yes")
          (setq note (getstring T "\nEnter note [<enter> to clear note]: "))
          )
        )
      (setq note (getstring T "\nEnter note: "))
      )
    )
  (if note
    (cond ((/= note "")
           (setq new_ent
                 (append (entget ent) (make-lst xapp note))
                 )
           (entmod new_ent))
          ((= note "")
           (setq new_ent
                 (append (entget ent)
                         (make-lst xapp (strcat "<removed by "(getvar 'loginname)">"))
                         )
                 )
           (entmod new_ent))
          )
    )
  (princ)
  )

(defun read-xdata (/ xapp ent xd)
  (setq xapp "user_xnote")
  (regapp xapp)

  (if (setq ent (car (entsel "\nSelect entity: ")))
    (setq xd (assoc -3 (entget ent (list xapp))))
    )

  (if xd
    (princ
      (strcat
        "\nNote: "
        (cdr (assoc 1000 (cdr (cadr xd))))
        "\nDate : "
        (rtos (cdr (assoc 1040 (cdr (cadr xd)))) 2 0)
        )
      )
    )
  (princ)
  )

(defun c:xNotes (/ kwd)
  (regapp "user_xnote")
  (initget "Add Read")
  (setq kwd
        (getkword "\nDo you want to Add or Read notes? (A/R) <Add>: ")
        )
  (cond ((or (= kwd nil)(= kwd "Add"))
         (set-xdata))
        ((= kwd "Read")
         (read-xdata))
        )
  )
TheSwamp.org  (serving the CAD community since 2003)

Water Bear

  • Guest
extended data routine :: beta testers wanted
« Reply #6 on: May 05, 2004, 10:07:49 AM »
Here's one just for comparison:
Code: [Select]
(defun C:STICKEMS ()

  (prompt "\nSTICKEMS - Attach notes to drawing entities")

  (initget 1 "R W")
  (setq CHOICE (getkword
"\nDo you want to Read or Write a note <R or W> ? "
)
)

  (while (null (setq ENTITY (car (entsel)))))

  (if (equal CHOICE "W")
    (progn

      (textpage)

      (setq NAME (getstring "\nWhat is your first name ? "))
      (setq NAME (strcat "STICKEMS"
(substr (rtos (getvar "CDATE") 2 8) 1 8)
(substr (rtos (getvar "CDATE") 2 8) 10 8)
NAME
)
   )
      (regapp NAME)

      (setq ENTLIST (entget ENTITY (list "*")))

      (prompt
"\nEnter your note line by line. When you are through"
)
      (prompt "\ntype the word EXIT on a line by itself.\n")

      (setq NEW_XDATA (list NAME (cons 1002 "{")))
      (while (/= "EXIT" (strcase (setq STRING (getstring T ">"))))
(setq NEW_XDATA (append NEW_XDATA (list (cons 1000 STRING))))
)
      (setq NEW_XDATA (append NEW_XDATA (list (cons 1002 "}"))))
      (setq NEW_XDATA (list -3 NEW_XDATA))

      (if (assoc -3 ENTLIST)
(setq NEW_ENTLIST (subst NEW_XDATA (assoc -3 ENTLIST) ENTLIST))
(setq NEW_ENTLIST (append ENTLIST (list NEW_XDATA)))
)
      (entmod NEW_ENTLIST)
      )
    )

  (if (equal CHOICE "R")
    (progn

      (setq ENTLIST (entget ENTITY (list "STICKEMS*")))
      (setq XDATA (cdr (assoc -3 ENTLIST)))

      (if (null XDATA)

(prompt "\nEntity does not have any STICKEMS.")

(progn
 (foreach ITEM XDATA

   (textpage)

   (setq DATE (substr (car ITEM) 9 8))
   (setq TIME (substr (car ITEM) 17 8))
   (setq NAME (substr (car ITEM) 25))

   (prompt (strcat "Posted by " NAME " on " DATE " at " TIME))

   (setq NOTES (cdr ITEM))
   (foreach LINE NOTES
     (if (= (car LINE) 1000)
(prompt (strcat "\n" (cdr LINE)))
)
     )

   (getstring "\n\nHit any key to continue ...")
   )
 )
)
      )
    )

  (prompt "\nProgram complete.")
  (princ)
  )

ronjonp

  • Needs a day job
  • Posts: 7526
extended data routine :: beta testers wanted
« Reply #7 on: May 05, 2004, 01:22:14 PM »
Work fine over here Mark.  :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
extended data routine :: beta testers wanted
« Reply #8 on: May 05, 2004, 03:07:32 PM »
Works really nice. I like it! :D
I drink beer and I know things....

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« Reply #9 on: May 05, 2004, 03:50:29 PM »
wait till you see the version !!
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« Reply #10 on: May 06, 2004, 07:43:04 AM »
New version, all GUI. please see included help file.

http://www.theswamp.org/swamp.files/Public/xNotes-0.3.zip
TheSwamp.org  (serving the CAD community since 2003)

hendie

  • Guest
extended data routine :: beta testers wanted
« Reply #11 on: May 06, 2004, 09:33:05 AM »
Mark, I noticed that if you select one of the predefined notes, it does not update in the textbox. However, it does update the note as you can verify when you activate it again.

hendie

  • Guest
extended data routine :: beta testers wanted
« Reply #12 on: May 06, 2004, 09:42:46 AM »
*idea* is there anyway you could incorporate a button/feature which would highlight all entites that already had xdata attached ?

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
extended data routine :: beta testers wanted
« Reply #13 on: May 06, 2004, 10:27:01 AM »
It hangs up my session of AutoCAD when I hit CANCEL. :?
2k2 LDD3
I drink beer and I know things....

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
extended data routine :: beta testers wanted
« Reply #14 on: May 06, 2004, 12:33:43 PM »
Quote from: Slim101
It hangs up my session of AutoCAD when I hit CANCEL. :?
2k2 LDD3


Does for me too! although it doesn't in Map. still digging ............
TheSwamp.org  (serving the CAD community since 2003)