- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone.
Previously, I used lisp EPD (downloaded from another topic), however, there were some obstacles, so I wrote this topic, hoping to receive help from autolisp experts.
Specifically:
I have 2 LWPolyline groups with text overlapping on the contour line, or inside.
After using lisp EPD (attached), the result I received was a csv file as shown below:
I would like to adjust lisp to achieve the following expectations.
1. The single-segment LWpolylines in Group 2: Could export the list of text that crossed (or overlap) with itself.
2. The LWpolylines in Group 1: Dont export the text that isn't crossed the line (i.e: Space 2,space3 with text W02). Keeping export text that cross and be inside the lwpolyline.
3. Text inside polyline (or crossed, or overlap etc..) - Column A: Sort by the Layer name first, then sort by the alphabet of content). with same serepate by " | "
Other columns: Area, Perimeter, Layer etc,.. please keep it,
There is ACAD file, CSV file, and the lisp file that I used.
I have actually searched the entire forum and really hope someone can help to adjust the lisp code, with at least one issue.
Edit: I post the lisp code EPD that I used
(defun c:EPD (/ all_data area csv_file d data e ent i len openfile pts s ss sstext st)
; Export Polyline Data
;; pBe Sep 2018 ;;
(if (and (setq ss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i)))
ent (entget e)
area (vlax-curve-getarea e)
;; RJP » 2019-01-17 added length to results
len (vlax-curve-getdistatparam e (vlax-curve-getendparam e))
data (mapcar '(lambda (d) (cdr (assoc d ent))) '(8 70 5))
pts (mapcar 'cdr (vl-remove-if-not '(lambda (d) (= 10 (car d))) ent))
)
(setq all_data
(cons
(list
(cond
((null (setq sstext (ssget "_CP" pts '((0 . "TEXT"))))) "-")
((= (sslength sstext) 1) (cdr (assoc 1 (entget (ssname sstext 0)))))
((substr
(apply
'strcat
(mapcar '(lambda (st) (strcat " | " st))
(vl-sort
(mapcar '(lambda (s) (cdr (assoc 1 (entget s))))
(vl-remove-if 'listp (mapcar 'cadr (ssnamex sstext)))
)
(function (lambda (a b) (< a b)))
)
)
)
4
)
)
)
area
len
(car data)
(if (zerop (logand 1 (cadr data)))
"No"
"Yes"
)
(caddr data)
)
all_data
)
)
all_data
)
(setq csv_file
(getfiled "Save CSV File"
(strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".csv")
"csv"
45
)
)
)
(progn (setq openfile (open csv_file "w"))
(write-line
"Text inside polyline?,Polyline Area (m2),Polyline Length (m),Layer,Closed?,Handle"
openfile
)
(foreach itm (vl-sort all_data '(lambda (a b) (< (cadr a) (cadr b))))
(write-line
(strcat (car itm)
","
(strcat (rtos (cadr itm) 2 2) )
","
(strcat (rtos (caddr itm) 2 2) )
","
(cadddr itm)
","
(cadddr (cdr itm))
","
(last itm)
)
openfile
)
)
(close openfile)
(startapp "notepad" csv_file)
)
)
(princ)
)
Solved! Go to Solution.