不太难
- (defun c:NdUpd (/ doc spc nd1 nd2 pl mtxt pt ndlst blk turns)
- (vl-load-com)
- (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
- spc (if (zerop (vla-get-activespace doc))
- (if (= (vla-get-mspace doc) :vlax-true)
- (vla-get-modelspace doc)
- (vla-get-paperspace doc))
- (vla-get-modelspace doc)))
- (if (or (tblsearch "BLOCK" "NODE")
- (findfile "NODE.dwg"))
- (if (and (setq nd1 (car (entsel "\nSelect Node 1: ")))
- (eq "INSERT" (cdadr (entget nd1)))
- (eq "PNODE" (strcase (cdr (assoc 2 (entget nd1))))))
- (if (and (setq nd2 (car (entsel "\nSelect Node 2: ")))
- (eq "INSERT" (cdadr (entget nd2)))
- (eq "PNODE" (strcase (cdr (assoc 2 (entget nd2))))))
- (if (and (setq pl (car (entsel "\nSelect Line Object: ")))
- (member (cdadr (entget pl)) '("LWPOLYLINE" "POLYLINE" "LINE")))
- (if (setq pt (getpoint "\nSelect Point for Block: "))
- (progn
- (and (setq mtxt (car (entsel "\nSelect MTEXT: ")))
- (wcmatch (cdadr (entget mtxt)) "*TEXT"))
- (setq turns (getint "\nSpecify Number of Turns: "))
- (setq ndlst
- (mapcar
- (function
- (lambda (x)
- (cdr (assoc 1 (entget (entnext x))))))
- (list nd1 nd2)))
- (setq blk
- (vla-insertblock spc
- (vlax-3D-point (trans pt 1 0)) "NODE.dwg" 1. 1. 1. 0.))
- (foreach att (vlax-safearray->list
- (vlax-variant-value
- (vla-getAttributes blk)))
- (cond ((eq "NODE1" (vla-get-TagString att))
- (vla-put-TextString att (car ndlst)))
- ((eq "NODE2" (vla-get-TagString att))
- (vla-put-TextString att (cadr ndlst)))
- ((eq "LENGTH" (vla-get-TagString att))
- (vla-put-TextString att
- (rtos
- (vla-get-Length
- (vlax-ename->vla-object pl)))))
- ((eq "TURNS" (vla-get-TagString att))
- (if turns
- (vla-put-TextString att
- (rtos turns))))
- ((eq "COIL" (vla-get-TagString att))
- (vla-put-TextString att
- (if mtxt
- (cdr (assoc 1 (entget mtxt))) ""))))))
- (princ "\n<!> No Point Selected <!>"))
- (princ "\n<!> Incorrect LINE Object Selection <!>"))
- (princ "\n<!> Incorrect Selection of NODE 2 <!>"))
- (princ "\n<!> Incorrect Selection of NODE 1 <!>"))
- (princ "\n<!> NODE Block not Found <!>"))
- (princ))
|