AutoCAD Table Field: How to Get Multiple Field Properties?

AutoCAD Table Field: How to Get Multiple Field Properties?

Anonymous
Not applicable
810 Views
1 Reply
Message 1 of 2

AutoCAD Table Field: How to Get Multiple Field Properties?

Anonymous
Not applicable

Is it possible to import multiple field values from my measurements into a table? Right now, to put a measurement into a table, I click the table, click "Field", go to "Objects", "Select Object", then click the measurement I need to reference, click the "Measurement" property, then "Additional Format", and type in my measurement suffix to match the floorplan (then "ok" "ok"). If this process could be shortened perhaps with a macro, or the field import both the measurement length and the suffix at once that would be appreciated, but I cannot figure out how to get a table to conjoin two field values.

 

Screen capture below.

0 Likes
811 Views
1 Reply
Reply (1)
Message 2 of 2

CodeDing
Advisor
Advisor

@Anonymous ,

 

Here give this a try. Working with tables is a pain IMO. This will have you select the table.. then repeatedly ask for cell, then dimension, cell, then dimension.

 

I understand that this does NOT provide the dynamic ability of a field, but it's a start.. Yes linking them as objects can be done, but I'll need more time.

(defun c:UT ( / *error* HitTest tbl osm pnt data dim str)
  ;; Update Table w/ dims
  ;; Helper Function(s)
  ;; Error handle
  (defun *error* (msg / )
    (if osm (setvar 'OSMODE osm))
    (if (not (member msg '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
    );if
    (princ)
  );defun
  ;; Hit Test
  (defun HitTest (pt obj / vd row col)
    ;; By user pbejse: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-cell-data-value-by-pick-point-in-cell/m-p/9326067#M396112
    (setq pt (vlax-3D-point (trans pt 1 0))
          vd (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0))
    );setq
    (if (eq :vlax-true (vla-hittest obj pt vd 'row 'col))
      (list obj row col)
    );if
  );defun
  ;; Prep
  (if (not (and (setq tbl (car (entsel "\nSelect Table: ")))
                (eq "ACAD_TABLE" (cdr (assoc 0 (entget tbl))))))
    (progn (prompt "\nBad Table selection.") (exit))
  );if
  (setq tbl (vlax-ename->vla-object tbl))
  (setq osm (getvar 'OSMODE)) (setvar 'OSMODE (logior 16384 osm))
  ;; Begin work
  (while (setq pnt (getpoint "\nSelect Cell in table: "))
    (if (and (setq data (HitTest pnt tbl))
             (setq dim (car (entsel "\nSelect Dimension Entity: ")))
             (eq "DIMENSION" (cdr (assoc 0 (entget dim))))
        );and
      (progn
        (setq str (strcat (getpropertyvalue dim "Prefix")
                          (rtos
                            (getpropertyvalue dim "Measurement")
                            (getpropertyvalue dim "Dimlunit")
                            (getpropertyvalue dim "Dimdec")
                          );rtos
                          (getpropertyvalue dim "Dimpost")
                  );strcat
        );setq
        (vlax-invoke-method tbl 'SetText (cadr data) (caddr data) str)
      );progn
    ;else
      (prompt "\nBad Selection. Try Again.")
    );if
  );while
(setvar 'OSMODE osm) (prompt "\nComplete.") (princ) );defun

Best,

~DD

0 Likes