extended data?

Discussion in 'AutoCAD' started by Jason Wilder, Sep 30, 2004.

  1. Jason Wilder

    Jason Wilder Guest

    It's been a little while since I've followed the newsgroup, but I've got new
    requests being made of me and need to start brushing up on my
    customizations.

    I vaguely remember there being a way to add data to an entity, so that it's
    there for routines or queries on a drawing for quantities, etc.

    Would any of you mind shooting me a few pointers, sites, or just give me a
    general idea on where/what I need to look for?

    I still have some routines stashed away that deal w/ creating/using user
    Dictionaries in a drawing that I'll begin playing with, but I need something
    at the entity level.

    Thank you for any pointers.
     
    Jason Wilder, Sep 30, 2004
    #1
  2. Here are some examples of using extended data -

    ;--register extended data for partname--------------------------
    (defun RegAppPN (/ APPNAME)
    (setq APPNAME "SSpart") ; Set application name
    (if (not (tblsearch "appid" APPNAME)) ; Checks if already registered
    (if (= (regapp APPNAME) nil) ; Register and check
    (alert (strcat "\nERROR - \n Can't register XDATA for " APPNAME
    ". "))
    )
    )
    (princ)
    )

    ;--subroutine to find Piece Extended Data value--------------------------
    (defun GET_PN (TT /) ;TT is text to display in selection
    (setq ES (entsel (strcat "\nSelect Piece for " TT " ? ")))
    (if ES
    (progn
    (setq EGE (entget (car ES) (list "SSpart")))
    (GET_PED EGE)
    )
    )
    )

    ;--subroutine to get PartName Extended Data
    value---------------------------
    (defun GET_PED (EGG /)
    (setq PART_NUM nil)
    (if (assoc -3 EGG)
    (setq PART_NUM (cdr (assoc 1000 (cdadr (assoc -3 EGG)))))
    )
    )

    ;--subroutine to save PartName Extended Data
    value--------------------------
    (defun SET_PED (EGG P_N / ED) ;EGG is entget list and P_N is text value
    (if P_N
    (progn
    (setq ED (list (list -3 (list "SSpart" (cons 1000 P_N)))))
    (setq EGG (append EGG ED))
    (entmod EGG)
    )
    )
    )

    ;LK = list Entity, Layer Name & Description for selected entity
    (defun C:LK (/ ES EGS EGE PN SN LAYNAM ET)
    (setq ES (entsel "\nSelect Entity to List ? "))
    (while ES
    (setq EGS (entget (car ES)))
    (setq EGE (entget (car ES) (list "SSpart")))
    (if (assoc -3 EGE)
    (setq PN (cdr (assoc 1000 (cdadr (assoc -3 EGE)))))
    (setq PN nil)
    )
    (if (assoc -3 EGN)
    (setq SN (cdr (assoc 1000 (cdadr (assoc -3 EGN)))))
    (setq SN nil)
    )
    (redraw (cdr (assoc -1 EGS)) 3)
    (setq LAYNAM (cdr (assoc 8 EGS)))
    (cond
    ((= (cdr (assoc 0 EGS)) "INSERT")
    (setq ET (strcat "Block [" (cdr (assoc 2 EGS)) "]"))
    )
    ((= (cdr (assoc 0 EGS)) "SHAPE")
    (setq ET (strcat "Shape [" (cdr (assoc 2 EGS)) "]"))
    )
    (T (setq ET (cdr (assoc 0 EGS))))
    )
    (princ (strcat "\n" ET " Layer=" LAYNAM))
    (if (member (cdr (assoc 0 EGS)) (list "TEXT" "DTEXT" "MTEXT" "ATTDEF"))
    (progn
    (princ (strcat " [" (cdr (assoc 1 EGS)) "]"))
    (princ (strcat " <Size=" (rtos (cdr (assoc 40 EGS)) 2 2) ">"))
    )
    )
    (if (member (cdr (assoc 0 EGS)) (list "INSERT" "SHAPE"))
    (princ (strcat " <Scale=" (rtos (cdr (assoc 41 EGS)) 2 2) ">"))
    )
    (if PN
    (princ (strcat " pn=" PN))
    )
    (if SN
    (princ (strcat " sn=" SN))
    )
    (setq ES (entsel "\nSelect Entity to List ? "))
    (redraw (cdr (assoc -1 EGS)) 4)
    )
    (redraw (cdr (assoc -1 EGS)) 4)
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, Sep 30, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.