Jump to content

table help-visual lisp- beginner


brams

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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