rodrigo_sjc_sp 发表于 2022-7-5 23:49:56

在单元格表中插入块

我在网上找到了一张样品表,这是我最想得到的帮助
在单元格中插入块
 
在下面的示例中,更精确地在单元格中插入一个块。
 
 


; load (vl-load-com) first
(vl-load-com)
(defun C:POLYTABLE ( / *MS* A CNT I LST MYTABLE PT1 ROW SSET TLST)
; create an empty list, set a counter variable, and
; set a reference to the current model space.
(setq lst '()
i 0
*ms* (vla-get-modelspace
            (vla-get-activedocument
            (vlax-get-acad-object)))
)
; prompt the user to select closed polylines
(princ "\n Select closed polylines ")
(if (setq sset (ssget '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1))))
   ; if a valid selection set was generated, then proceed.
   (progn
   
   ; for each closed polyline selected, grab the ObjectID and Area
   ; and store these values in a list.
   (repeat (setq cnt (sslength sset))
       (setq a (vlax-ename->vla-object (ssname sset i)))
       (setq tlst (list (vla-get-Area a) (vla-get-ObjectID a)))
       (setq lst (cons tlst lst))
       (setq i (1+ i))
   )
   ; pick a point for the table
   (setq pt1 (getpoint "\nPick point for table "))
   ; add the new table
   (setq myTable (vla-AddTable
                   *ms*
                   (vlax-3d-point pt1)
                   (+ 3 cnt)
                   2
                   0.7
                   2.5))
   ; the next three lines set the header text
   (vla-setText mytable 0 0 "Polyline Table")
   (vla-setText mytable 1 0 "Area")
   (vla-setText mytable 1 1 "Object ID")
   (setq row 2)
   
   ; loop through the list of polyline properties
   ; adding a line to the table that contains the
   ; area and the ObjectID
   (foreach item lst
       (vla-setText mytable
                  row
                  0
                  (strcat "%%).Area \\f \"%lu2\">%"))
       (vla-setText mytable row 1 (last item))
       (setq row (1+ row))
   )      
   ; On the last row, total up the area
   (vla-setText mytable
                  row
                  0
                  (strcat "Total=\\P"
                  "%%"))
   ; release "myTable" and *ms*
   (vlax-release-object myTable)      
   (vlax-release-object *ms*)      
   ); end progn
; if no closed polylines were selected,
; end the program with this message
   (princ "\nNo closed polylines selected. ")
); end if
(princ)
); end defun

rodrigo_sjc_sp 发表于 2022-7-6 00:20:00

下面这行是在单元格中插入文本,
需要知道如何在单元格中插入块。
 
块已插入DWG文件中,那么我相信它只会
与输入的单元格块关联。
 
谁能给我一个主意吗?
 
 
 
 
 

(vla-setText mytable 1 1 "Object ID")

Lee Mac 发表于 2022-7-6 01:02:07

你可以遵循我在这个程序中使用的相同方法。
 
页: [1]
查看完整版本: 在单元格表中插入块