Search the Community
Showing results for tags 'lwpolyline'.
-
Finding polylines within others, in a selection
X11start posted a topic in AutoLISP, Visual LISP & DCL
I have created a lisp that I routinely use to successively print various boards (A4 and A3 size), arranged in model space. Basically, the command asks to select the tables I intend to print and as print coordinates it uses the frames (lwpolyline) it finds on layer "ZZ_FORMED". (setq selpol(ssget (LIST (cons -4 "<AND") (cons 0 "LWPOLYLINE") (cons 8 "ZZ_FORMED") (cons -4 "AND>") ) )) The problem arises when by mistake, there are 2 overlapping panes, or one is inside another: e.g., the format frame that is also on layer "ZZ_FORMED", instead of on another layer that the lisp would ignore. In these cases my drawing is mistakenly printed 2 times, once by taking the correct format and the other by taking the slightly smaller frame. I would therefore like to find a way to find the error, which would allow me to stop my lisp and report the incorrect frame .... with a nice circle! The workflow I thought I would use is as follows: - I scroll one by one through all the selected polylines that are on the "ZZ_FORMED" layer. - I create a list containing the vertices, of each polyline found. - I create a second list containing the center of gravity (intersection point of the 1st with the 3rd vertex and the 2nd with the 4th). - I scroll through the found barycenters one by one and check whether they lie within, not only the list of points considered but also of another list. If so, it means that point is internal, not only of the figure whose barycenter it is, but also of another: so it is an error. I don't know if this is the correct flow or if there are faster solutions: I would like to avoid writing pages and pages of code, only to then find out that with 4 VL-xx commands everything could be done! -
Intersections Between Lines at different Elevations
Jaru posted a topic in AutoLISP, Visual LISP & DCL
Hi There is a situation what I need is a lisp routine or vba script to find the elevations between lines or polylines at the intersection points of them to better reflect my query I post an image. I thank you in advance for the help provided. Elevation-Case.bmp -
Hi all, I found this LISP routine by Tony Hotchkiss from here. If I understood this correct, it works with LWPolyline, Polyline and Point. For some reason it does not work will all polylines on my drawing. The sample drawing is provided below and attached with this thread https://drive.google.com/file/d/1bLurrxbnH6c9Fee5L4qIc0okwdVU0b9W/view?usp=sharing (defun vert (/ filterlist vla-obj-list lwlist 2dlist ptlist vlist1 vlist2 vlist3 ) (vl-load-com) (setq filterlist (make-filter) vla-obj-list (get-objects filterlist) lwlist (nth 0 vla-obj-list) 2dlist (nth 1 vla-obj-list) ptlist (nth 2 vla-obj-list) vlist1 nil vlist2 nil vlist3 nil ) ;_ end-of setq (if lwlist (setq vlist1 (make-list lwlist 2)) ) ;_ end of if (if 2dlist (setq vlist2 (make-list 2dlist 3)) ) ;_ end of if (if ptlist (setq vlist3 (make-list ptlist 3)) ) ;_ end of if (write-text vlist1 vlist2 vlist3) (princ) ) ;_ end of vert (defun make-list (p-list n / i vlist obj coords ca j x y z xy) (setq i (- 1) vlist nil ) ;_ end of setq (repeat (length p-list) (setq obj (nth (setq i (1+ i)) p-list) coords (vlax-get-property obj "coordinates") ca (vlax-variant-value coords) j (- 1) ) ;_ end-of setq (repeat (/ (length (vlax-safearray->list ca)) n) (setq x (vlax-safearray-get-element ca (setq j (1+ j)))) (setq y (vlax-safearray-get-element ca (setq j (1+ j)))) (if (= n 2) (setq xy (list x y)) (progn (setq z (vlax-safearray-get-element ca (setq j (1+ j)))) (setq xy (list x y z)) ) ;_ end of progn ) ;_ end of if (setq vlist (append vlist (list xy))) ) ;_ end-of repeat ) ;_ end-of repeat ) ;_ end-of make-list (defun make-filter (/ filter) (setq filter '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "POLYLINE") (0 . "POINT") (-4 . "OR>") ) ) ;_ end of setq ) ;_ end of make-filter (defun get-objects (filter / ss k lwp-list 2dp-list pt-list no-ent obj pl 2d pt ) (setq no-ent 1) (while no-ent (setq ss (ssget filter) k (- 1) lwp-list nil 2dp-list nil pt-list nil obj nil pl "AcDbPolyline" 2d "AcDb2dPolyline" pt "AcDbPoint" ) ;_ end-of setq (if ss (progn (setq no-ent nil) (repeat (sslength ss) (setq ent (ssname ss (setq k (1+ k))) obj (vlax-ename->vla-object ent) ) ;_ end-of setq (cond ((= (vlax-get-property obj "ObjectName") pl) (setq lwp-list (append lwp-list (list obj))) ) ((= (vlax-get-property obj "ObjectName") 2d) (setq 2dp-list (append 2dp-list (list obj))) ) ((= (vlax-get-property obj "ObjectName") pt) (setq pt-list (append pt-list (list obj))) ) ) ;_ end-of cond ) ;_ end-of repeat ) ;_ end-of progn (prompt "\nNo polylines or points selected, try again.") ) ;_ end-of if ) ;_ end-of while (list lwp-list 2dp-list pt-list) ) ;_ end-of get-objects (defun write-text (vl1 vl2 vl3) (setq fn (getfiled "Text File" "" "txt" 1)) (setq f (close (open fn "w"))) (setq msg "Points from LW-Polylines") (do-points fn vl1 msg 2) (setq msg "Points from 2d-Polylines") (do-points fn vl2 msg 3) (setq msg "Points from Point entities") (do-points fn vl3 msg 3) (princ) ) ;_ end of write-text (defun do-points (fn vl msg n) (setq f (open fn "a")) (write-line msg f) (write-line " x, y, z" f) (write-line "" f) (foreach point vl (setq x (nth 0 point) y (nth 1 point) ) ;_ end of setq (if (= n 2) (setq str (strcat (rtos x) "," (rtos y))) (progn (setq z (nth 2 point)) (setq str (strcat (rtos x) "," (rtos y) "," (rtos z))) ) ;_ end of progn ) ;_ end of if (write-line str f) ) ;_ end of foreach (setq f (close f)) (princ) ) ;_ end of defun (defun c:pts () (vert) (princ) ) ;_ end-of defun (prompt "PLIST.LSP by Tony Hotchkiss - enter PTS to start ") I am new in AutoLISP so I would appreciate if you could suggest me how this code can be modified to export all the coordinates of polylines for my sample drawing. Or maybe my drawing can be modified using another LISP routine. In addition, I want the program to output two files. The first file would be the XY coordinates of all points of the polylines with number (kind of identification). For example, The second file would include the points and distances between them. For example, Thank you Best wishes, Jes G Sample.dwg
- 4 replies
-
- export
- export coordinates
-
(and 2 more)
Tagged with:
-
I'm working with C3D 2011. I have a large number of EP shots along a roadway. I drew a lwpolyline connecting each point with a node snap (the entire line is at the elevation of the first point). I need each polyline vertex at the EP elevation. Is there a way to convert my existing lwpolyline to a 3dpolyline AND have each vertex of the 3dpolyline inherit the elevation of the EP point/node that it was snapped to without redrawing the whole line using the 3dpoly command? Thanks all
-
- 3dpolyline
- 3dpoly
-
(and 1 more)
Tagged with: