有几个问题是线总是1-x等,它们是按1->16的顺序绘制的,这意味着只需选择线并从一个数字开始,例如1。
- ; http://www.theswamp.org/index.php?topic=57753.0
- ; simple table example lines to table
- l By AlanH Aug 2022
- (defun rtd (a)
- (/ (* a 180.0) pi)
- )
- (defun pl-table ( / ss sp curspace tableobj k totlen x len ang rownum)
- (setq ss (ssget (list (cons 0 "LWPOLYLINE"))))
- (setq sp (vlax-3d-point (getpoint "\nPick point for top left of table ")))
- (Setq curspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
- (setq tableobj (vla-addtable curspace sp 2 3 1 25))
- (vla-settext tableobj 0 0 "Heading")
- (vla-settext tableobj 1 0 "No.")
- (vla-settext tableobj 1 1 "Length")
- (vla-settext tableobj 1 2 "Angle")
- (setq k 0 totlen 0.0)
- (repeat (setq x (sslength ss))
- (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
- (setq totlen (+ totlen (vlax-get obj 'Length)))
- (setq len (strcat (rtos (vlax-get obj 'Length) 2 2) " m"))
- (setq ang (rtd (angle (vlax-curve-getstartPoint obj)(vlax-curve-getEndPoint obj))))
- (if (> ang 180.0)
- (setq ang (rtos (- ang 360.0) 2 0))
- (setq ang (rtos ang 2 0))
- )
- (setq tableobj (vlax-ename->vla-object (entlast)))
- (setq rownum (vla-get-rows tableobj))
- (vla-InsertRows tableobj rownum (vla-GetRowHeight tableobj (- rownum 1)) 1)
- (vla-settext tableobj rownum 0 (rtos (setq K (1+ k)) 2 0))
- (vla-settext tableobj rownum 1 len)
- (vla-settext tableobj rownum 2 ang)
- )
- (setq tableobj (vlax-ename->vla-object (entlast)))
- (setq rownum (vla-get-rows tableobj))
- (vla-InsertRows tableobj rownum (vla-GetRowHeight tableobj (- rownum 1)) 1)
- (vla-settext tableobj rownum 0 "Total")
- (vla-settext tableobj rownum 1 (strcat (rtos totlen 2 0) " m"))
- (princ)
- )
- (pl-table)
当它要求选择对象类型F并且可以在红线上拖动线时,按两次enter键结束选择,然后选择一个点。
|