jes\u g,
这是我周五下午的尝试。
假设您的数据(序列号?)包含在每个块的属性中;
提取第一个属性值(序列号);
1选择多段线;然后
2选择块。
将(在选定的多段线上)在每个块的最近点处放置一个点;和
数据将保存到CSV文件中
- (defun C:ODATA (/ pl s fn opn i e de dp )
- (vl-load-com)
- (setvar 'pdmode 3)
- (while
- (progn
- (setvar 'errno 0)
- (setq pl
- (car (entsel "\nSelect Polyline: ")
- ) ;_ end of car
- ) ;_ end of setq
- (cond
- ((= 7 (getvar 'errno))
- (princ "\nMissed, Please Try Again.")
- )
- ((/= "LWPOLYLINE" (cdr (assoc 0 (entget pl))))
- (princ
- "\nThe Selected Entity is not a LWPOLYLINE."
- ) ;_ end of princ
- )
- ) ;_ end of cond
- ) ;_ end of progn
- ) ;_ end of while
- (prompt "\nSelect **Attributed** Blocks to Process: ")
- (if (and (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1))))
- (setq fn (getfiled "Save Block Data to CSV File"
- (vl-filename-base (getvar 'dwgname))
- "csv"
- 1
- ) ;_ end of getfiled
- ) ;_ end of setq
- (setq opn (open fn "w"))
- ) ;_ end of and
-
- (progn
- (write-line
- (strcat
- "SERIAL NUMBER (ATTRIBUTE)"
- ","
- "ELEC LINE VERTEX EASTING"
- ","
- "ELEC LINE VERTEX NORTHING"
- ","
- "BLOCK INSERTION EASTING"
- ","
- "BLOCK INSERTION NORTHING"
- ) ;_ end of strcat
- opn
- ) ;_ end of write-line
-
- (close opn)
- (setq opn (open fn "a"))
- (repeat (setq i (sslength s))
- (setq e (vlax-ename->vla-object (ssname s (setq i (1- i)))))
- (setq
- de (vlax-get e 'insertionpoint)
- dp (vlax-curve-getclosestpointto pl de)
- ) ;_ end of setq
- (vl-cmdf "_.point" dp "")
- (write-line
- (strcat
- (vla-get-textstring (car (vlax-invoke e 'getattributes)))
- ","
- (rtos (car dp) 2 4)
- ","
- (rtos (cadr dp) 2 4)
- ","
- (rtos (car de) 2 4)
- ","
- (rtos (cadr de) 2 4)
- ) ;_ end of strcat
- opn
- ) ;_ end of write-line
- ) ;_ end of repeat
- ) ;_ end of progn
- ) ;_ end of if
- (close opn)
- (princ)
- ) ;_ end of defun
我不是专家,但希望这能让你更接近你想要的解决方案。
干杯
奥达塔。lsp |