brams 发表于 2022-7-6 07:50:24

table help-visual lisp- beginn

Hi Guys,
I work on a lisp that will extract radius from circles in a drawing and insert these values in a table (and a number for each circle...). I want to use data taken from some cells, i don't know how. Any help? Some example? Some links? Some tutorials for table in visual lisp? Thanks!

Lee Mac 发表于 2022-7-6 08:01:16

Since operations involving Table values in most cases involve specification of a row and column, the VLA Table Object is predominantly manipulated using Visual LISP methods rather than properties (which only use a single parameter).
 
To find the properties and methods associated with a Table Object, use the vlax-dump-object function:
 

(defun c:dump ( / en )   (if (setq en (car (entsel)))       (vlax-dump-object (vlax-ename->vla-object en) t)   )   (princ))(vl-load-com) (princ)You can then find information about each of these methods in the Visual LISP IDE Help Documentation; the documentation is written for VBA, but the parameter data types and their order translate directly to Visual LISP in most cases.
 
To retrieve data from Table Cells, look specifically into the GetText / GetValue / GetCellValue methods.

brams 发表于 2022-7-6 08:08:24

Best answer possible. Thanks, Lee

Lee Mac 发表于 2022-7-6 08:13:07

You're welcome, ask if you need further assistance

Tharwat 发表于 2022-7-6 08:26:16

What you mean by this .... ?
 

brams 发表于 2022-7-6 08:33:53

A order number - in table and in circle's center.

Tharwat 发表于 2022-7-6 08:40:48

Things like this .... ?
 

(defun c:Test (/ hgt spc d dia e ents inc increment Layers            insertionPoint tbl lengths lst r selectionset integer            selectionsetname             ) (vl-load-com);;; Tharwat 21 . June . 2012 ;;; (if (not acdoc)   (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq spc (if (> (vla-get-activespace acdoc) 0)             (vla-get-modelspace acdoc)             (vla-get-paperspace acdoc)         ) ) (setq   hgt (if         (zerop         (cdr             (assoc               40               (setq               e (entget (tblobjname "STYLE" (getvar 'textstyle)))               )             )         )         )          (cdr (assoc 42 e))          (cdr (assoc 40 e))       ) ) (setq increment 1) (if (setq selectionset (ssget (list '(0 . "CIRCLE"))))   (progn   (repeat (setq integer (sslength selectionset))       (setq selectionsetname            (ssname selectionset                      (setq integer (1- integer))            )       )       (setq dia            (cons                (cons (* (cdr (assoc 40 (entget selectionsetname))) 2.)                      (itoa increment)                )                dia            )       )       (setq ents (cons selectionsetname ents))       (setq increment (1+ increment))   )   ) ) (if (and dia          (setq insertionPoint (getpoint "\n Specify Table Location :"))   )   (progn   (setq tbl (vla-addtable               spc               (vlax-3d-point insertionPoint)               (+ (length dia) 2)               2               (* hgt 2.5)               (* hgt 2.5)               )   )   (setq inc -1         r   1   )   (repeat 2       (vla-setcolumnwidth tbl 0 (* hgt 10.))       (vla-setcolumnwidth tbl 1 (* hgt 10.))       (vla-setrowheight tbl (setq inc (1+ inc)) (* hgt 1.5))   )   (vla-settext tbl 0 0 "Circle's Diameters")   (vla-settext tbl 1 0 "Reference No.")   (vla-settext tbl 1 1 "Diameter Value")   (foreach x (reverse dia)       (vla-settext tbl (setq r (1+ r)) 0 (cdr x))       (vla-setcellalignment tbl r 0 acMiddleCenter)       (vla-settext tbl r 1 (rtos (car x) 2))       (vla-setcellalignment tbl r 1 acMiddleCenter)   )   (setq increment 1)   (foreach p (reverse ents)       (setq d (* (cdr (assoc 40 (entget p))) 2.))       (entmakex (list '(0 . "TEXT")                     (assoc 10 (entget p))                     (cons 11 (cdr (assoc 10 (entget p))))                     (cons 40                           (if (> increment 9)                               (/ d 1.5)                               (if (> hgt d)                                 d                                 hgt                               )                           )                     )                     (cons 1 (itoa increment))                     '(72 . 1)                     '(73 . 2)               )       )       (setq increment (1+ increment))   )   ) ) (princ "\n Written by Tharwat Al Shoufi") (princ))

brams 发表于 2022-7-6 08:45:26

Thanks, Tharwat.

Tharwat 发表于 2022-7-6 08:57:10

 
You're welcome brams
页: [1]
查看完整版本: table help-visual lisp- beginn