38
83
53
初露锋芒
使用道具 举报
4
24
16
初来乍到
1265
1028
后起之秀
1
1069
1050
;; first lisp;; xar.lsp;; first select one by one all what you need with accuracy;; and add xdata(vl-load-com)(defun C:XAR (/ )(setq osm (getvar "osmode")); store osmode(setvar "osmode" 512)(setvar "cmdecho" 0); turn echo off(regapp "PIPEINFO"); first of register application in ACAD.;; This would be stored in the table APPID;; loop through selected plines:(while(setq pickpt (getpoint "\nPick point on pline (hit Enter to exit loop): ")); pick point on entity(setq ps (getreal "\nPipe size: ") ln (getreal "\nLength: ") hws (getstring T "\nHWS: ") hwr (getstring T "\nHWR: ") )(setq en (ssname (ssget "C" pickpt pickpt (list (cons 0 "*POLYLINE")))0))(setq elist (entget en));build extension data (setqxdata (list(list -3 (list "PIPEINFO" (cons 1040 ps);real (cons 1041 ln);distance (cons 1000 hws);string (cons 1000 hwr);string ))))(setq xdlist (append elist xdata));append extension data to entity list(entmod xdlist); setting data, modify entity list(entupd en); update entity, optonal); end loop(setvar "osmode" osm); restore osmode(setvar "cmdecho" 1); turn echo on (princ))(prompt "\n\t\t\t |-----------------------------|")(prompt "\n\t\t\t <| Start with XAR to execute |>")(prompt "\n\t\t\t |-----------------------------|") (princ);; second lisp;; art.lsp;; here is follows part to draw the table (vl-load-com);; local defuns:; read extension data:(defun get_xdata (vobj apname)(or (vl-load-com))(if (and vobj apname)(progn(vla-getxdata vobj apname 'xtypeOut 'xdataOut) (setq xtp (vlax-safearray->list xtypeOut))(setq dtp (mapcar (function (lambda (x) (vlax-variant-value x))) (vlax-safearray->list xdataOut)))dtp)));Then you can get all xdata:(defun getallxdata (appname / acapp adoc axss table_data tmp) (or (vl-load-com)) (or acapp (setq acapp (vlax-get-acad-object))) (or adoc (setq adoc (vla-get-activedocument acapp))) (if (ssget "X" (list (cons 0 "*POLYLINE") (list -3 (list appname)))) (progn (setq axss (vla-get-activeselectionset adoc)) (vlax-for a axss (if (setq tmp (cdr (get_xdata a appname))) (setq table_data (cons tmp table_data)))))) (reverse table_data) );; create table style(defun make-tablestyle ( name desc txtstyle h1 h2 h3 / tblstyle adoc) (or (vl-load-com)) (setq tblstyle (vla-addobject (vla-item (vla-get-dictionaries (setq adoc (vla-get-activedocument (vlax-get-acad-object))) ) "Acad_Tablestyle" ) name "AcDbTableStyle" ) ) (setq acmCol (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2)))) (vla-put-name tblstyle name)