I have a two different lisp for the two different drawings, In the first drawing will find out the distance of each intersecting line from starting point of the polyline and identify the layer of intersecting line and Place Text chainage and crossings. And Second Drawing mark Chainge in "Km" Existings MText.
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Need Separately lisp, every intersection point create Polyline to choose the point one by one with crossing layer. View sample copy.
Hi sanju,
a little advice first. There are certainly more polite ways how to ask for something than start with "Need". If you have some language limitations, than use this for help. Also is appropriate mark answers as solution if it is, and give some kudo if you like the answer. These will help you get the solution easier and earlier from users who were more willing.
So back this one. Try this code.
(vl-load-com) (defun C:PipeAcrossLine ( / LM:GetInters LM:UniqueFuzz :SortPtListByDist ss en play ptslay) ;----- Lee Mac ~ 19.01.10 www.theswamp.org (modified) (defun LM:GetInters (ss / list->3D-point i j obj1 obj2 iLst pts lay1 lay2) (defun list->3D-point (lst) (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (list->3D-point (cdddr lst))))) (setq i (sslength ss)) (while (not (minusp (setq j (1- i) i (1- i)))) (setq obj1 (vlax-ename->vla-object (ssname ss i)) lay1 (vla-get-layer obj1)) (while (not (minusp (setq j (1- j)))) (setq obj2 (vlax-ename->vla-object (ssname ss j)) iLst (append iLst (setq pts (list->3D-point (vlax-invoke obj1 'IntersectWith obj2 acExtendNone)))) lay2 (if (eq play lay1) (vla-get-layer obj2) lay1)) (foreach e pts (setq ptslay (append ptslay (list (list e lay2))))) )) iLst) ;----- Lee Mac, http://www.lee-mac.com/uniqueduplicate.html (defun LM:UniqueFuzz (l f) (if l (cons (car l) (LM:UniqueFuzz (vl-remove-if (function (lambda ( x ) (equal x (car l) f))) (cdr l)) f)))) ;--------------------------------------------------------------------------------------------------------------------------- (if (and (princ "\nSelect ALL (poly)lines,") (setq ss (ssget '((0 . "*LINE,ARC")))) (not (initget 0)) (setq en (car (entsel "\nSelect a PIPELINE: "))) (wcmatch (cdr (assoc 0 (entget en))) "*LINE") (setq play (cdr (assoc 8 (entget en)))) (not (command "_.ZOOM" "_O" en "")) ) (foreach e (vl-remove-if-not '(lambda (pt) (vlax-curve-getDistAtPoint en pt)) (LM:UniqueFuzz (LM:GetInters ss) 0.001)) (entmake (list (cons 0 "LINE") (cons 10 (polar e (+ (* 0.5 pi) (setq ang (angle '(0 0 0) (vlax-curve-getFirstDeriv en (vlax-curve-getParamAtPoint en e))))) 5000)) (cons 11 (polar e (+ (* 1.5 pi) ang) 5000)) (cons 8 (last (assoc e ptslay))) (cons 210 '(0. 0. 1.)) ))) (princ "\nWrong selection.")) (command "_.ZOOM" "_P") (princ) )
BTW. Second thread, where you asked for vertex labeling, you did not attech a sample file.
Sir, my English is not very well, I am trying to learn to English. the next time I'll take care of that, Thanks for your advice. And secondly, it is possible to generate polyline which pick point one by one. This is because of two reasons, first reason is the file size is pretty high which is very time consuming. and second reason is River, Road, Highway there are two edge, It is only in single crossing. It is no fault on your Lisp
@Anonymous wrote:
I have attached the file of the real map. I thought that if a Pick Point at Place line one by one then isolated him and then it's use your Lisp "Pipe Across State" will work quickly. So Please give me lisp Just like that “Place Polyline One By One Pick.txt” lisp as it is same.
Ok man, the last piece for you.
But I'm lost in your samples...! Please post your "real map" again... with desired result as well. If you want to make the lisp procedure similar to some other routine, post it (and just that, not like like dozens of others..) - i'll take a look if that is even possible.
Sir, please add two option in your "PipeAcrossLine" lisp. first manually (section) Pick point of each crossings and Second option set manually AcrossLine length. Thank you.
I decided make separate routines.
MPipeAcrossStat
(defun c:MPipeAcrossStat ( / *error* adoc oOSMODE en play pt ss p file em m txt lay) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (if file (close file)) (prompt (strcat "\nValues of text height and dimensioning line were saved. \nType \"(setq #h nil)\" or \"(setq #y nil)\" for prompt to set new values next run of MPipeAcrossStat.")) (setvar 'OSMODE oOSMODE) (vla-endundomark adoc) (princ)) (setq oOSMODE (getvar 'OSMODE)) (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))) (if (and (not (initget 0)) (setq en (car (entsel "\nSelect a PIPELINE: "))) (wcmatch (cdr (assoc 0 (entget en))) "*LINE") (setq play (cdr (assoc 8 (entget en)))) (or #h (setq #h (cond ((getdist (strcat "\nSet text height <20>: "))) ;set default TEXT HEIGHT (20)))) ;set default TEXT HEIGHT (same as above) (or #y (progn (initget 0) (setq #y (cadr (getpoint "\nPick a dimensioning line: "))))) (setq #n (cond ((getint (strcat "\nStart with number <" (itoa (cond (#n) (1))) ">: "))) (#n) (1))) (setvar 'OSMODE 32) (setq file (open (strcat (getvar 'DWGPREFIX) (vl-string-right-trim ".dwg" (getvar 'DWGNAME)) ".csv") "a")) (if (= #n 1) (write-line "Number,Layer Cross Polyline,Easting,Northing,Elevation,Chainage,Between TP" file) T) ) (while (/= "eXit" (progn (initget "eXit") (setq pt (getpoint (strcat "\nPick crossing #" (itoa #n) " [eXit]: "))))) (if (and (= (type pt) 'LIST) (setq ss (ssget "_C" (polar pt (* 1.25 pi) 0.01) (polar pt (* 0.25 pi) 0.01) (list '(-4 . "<NOT") (cons 8 (strcat play ",TEXT COVER")) '(-4 . "NOT>"))) em (cond ((and ss (= 1 (sslength ss))) (ssname ss 0)) (T (car (entsel "\nSelect crossing line <skip>: "))))) (setq lay (strcase (cdr (assoc 8 (entget em)))) txt (strcat "TP" (itoa (setq p (fix (vlax-curve-getParamAtPoint en (setq pt (vlax-curve-getClosestPointTo en pt)))))) " - TP" (itoa (1+ p)) "\\PCS-" (substr "00" 1 (if (>= 2 (strlen (setq m (itoa #n)))) (- 2 (strlen m)) 0)) m "/" lay "\\PCH." (rtos (setq s (vlax-curve-getDistAtPoint en pt)) 2 2) "m" )) ) (progn (entmake (list (cons 0 "LINE") (cons 10 pt) (cons 11 (list (car pt) #y 0.)) (cons 8 "TEXT COVER") (cons 62 210) (cons 210 '(0. 0. 1.)) )) (entmake (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 8 "TEXT COVER") (cons 10 (list (car pt) #y 0.)) (cons 40 #h) (cons 50 (* 0.5 pi)) (cons 1 txt) (cons 71 4) (cons 62 1) (cons 63 2) (cons 90 1) )) (write-line (strcat (itoa #n) "," lay "," (rtos (car pt) 2 3) "," (rtos (cadr pt) 2 3) "," "0" "," (rtos s 2 3) "," "TP" (itoa p) " - TP" (itoa (1+ p)) ) file) (setq #n (1+ #n)) (vla-endundomark adoc) (vla-startundomark adoc))))) (*error* "end") )
MPipeAcrossLine
(defun c:MPipeAcrossLine ( / *error* adoc oOSMODE en play pt em ss lay) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (setvar 'OSMODE oOSMODE) (prompt (strcat "\nValue of length was saved. \nType \"(setq #L nil)\" for prompt to set new values next run of MPipeAcrossStat.")) (vla-endundomark adoc) (princ)) (setq oOSMODE (getvar 'OSMODE)) (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))) (if (and (not (initget 0)) (setq en (car (entsel "\nSelect a PIPELINE: "))) (wcmatch (cdr (assoc 0 (entget en))) "*LINE") (setq play (cdr (assoc 8 (entget en)))) (or #l (progn (initget 7) (setq #l (getdist "\nSet length of perpendicular line: ")))) (setvar 'OSMODE 32) ) (while (/= "eXit" (progn (initget "eXit") (setq pt (getpoint (strcat "\nPick crossing [eXit]: "))))) (if (and (= (type pt) 'LIST) (setq ss (ssget "_C" (polar pt (* 1.25 pi) 0.01) (polar pt (* 0.25 pi) 0.01) (list '(-4 . "<NOT") (cons 8 (strcat play ",TEXT COVER")) '(-4 . "NOT>"))) em (cond ((and ss (= 1 (sslength ss))) (ssname ss 0)) (T (car (entsel "\nSelect crossing line <next>: "))))) (setq lay (strcase (cdr (assoc 8 (entget em))))) ) (entmake (list (cons 0 "LINE") (cons 10 (polar pt (+ (* 0.5 pi) (setq ang (angle '(0 0 0) (vlax-curve-getFirstDeriv en (vlax-curve-getParamAtPoint en (vlax-curve-getClosestPointTo en pt)))))) (* 0.5 #l))) (cons 11 (polar pt (+ (* 1.5 pi) ang) (* 0.5 #l))) (cons 8 lay) (cons 210 '(0. 0. 1.)) ))))) (*error* "end") )
- I had to get back to problematic layer selection (recognition)... But now it recognize a potential problem automatically and you'll get a chance to select that manually.
- it's reporting chainage to *.csv. This file is created automatically and always, but all new lines are added (just added)) at the very end of the file. The file is never cleared (you can do that manually in your file manager). Because of that, I added cross-number (rank) into reported line (first statement) for better sorting...
- you have possibility to set text number... This prompt appears by first run only, next ruin is skipped and used the previous value. If you wanna change the value, use (setq #h nil) - then you'll get the prompt with next run of routine. Similar behaviour is for dimensioning line (setq #h nil) and length of line in MPileAcrossLine (setq #L nil). You type that into command line inc. parenthesis.
BeekeeCZ, Again, thank you very much, you have helped me a lot. With this time without hanging is extremely easy to operate.
(defun C:MPipeAcrossStat ( / LM:GetInters LM:UniqueFuzz :SortPtListByDist ss en y n m l p s txt play ptslay) (vl-load-com) ;----- Lee Mac ~ 19.01.10 www.theswamp.org (modified) (defun LM:GetInters (ss / list->3D-point i j obj1 obj2 iLst pts lay1 lay2) (defun list->3D-point (lst) (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (list->3D-point (cdddr lst))))) (setq i (sslength ss)) (while (not (minusp (setq j (1- i) i (1- i)))) (setq obj1 (vlax-ename->vla-object (ssname ss i)) lay1 (vla-get-layer obj1)) (while (not (minusp (setq j (1- j)))) (setq obj2 (vlax-ename->vla-object (ssname ss j)) iLst (append iLst (setq pts (list->3D-point (vlax-invoke obj1 'IntersectWith obj2 acExtendNone)))) lay2 (if (eq play lay1) (vla-get-layer obj2) lay1)) (foreach e pts (setq ptslay (append ptslay (list (list e lay2))))) )) iLst) ;----- Lee Mac, http://www.lee-mac.com/uniqueduplicate.html (defun LM:UniqueFuzz (l f) (if l (cons (car l) (LM:UniqueFuzz (vl-remove-if (function (lambda ( x ) (equal x (car l) f))) (cdr l)) f)))) ;----- BlackBox, http://www.cadtutor.net/forum/showthread.php?61433-Help-Sort-a-list-point-by-distance (defun :SortPtByDist (ptList en) (mapcar '(lambda (x / ptList2) (setq ptList2 (append (cdr x) ptList2))) (vl-sort (mapcar '(lambda (x / pt ptlist2) (setq ptlist2 (append (cons (vlax-curve-getDistAtPoint en (vlax-curve-getClosestPointTo en x T)) x) ptlist2))) ptList) '(lambda (x y) (< (car x) (car y)))))) ;--------------------------------------------------------------------------------------------------------------------------- (if (and (princ "\nSelect ALL (poly)lines,") (setq ss (ssget '((0 . "*LINE,ARC")))) (not (initget 0)) (setq en (car (entsel "\nSelect a PIPELINE: "))) (wcmatch (cdr (assoc 0 (entget en))) "*LINE") (setq play (cdr (assoc 8 (entget en)))) (not (initget 0)) (setq y (cadr (getpoint "\nPick a dimension line: "))) (setq n 0) (not (command "_.ZOOM" "_O" en "")) (not (terpri)) (princ "\nCrossings,Easting,Northing,Elevation,Chainage,Between TP") ) (foreach e (:SortPtByDist (vl-remove-if-not '(lambda (pt) (vlax-curve-getDistAtPoint en pt)) (LM:UniqueFuzz (LM:GetInters ss) 0.001)) en) (setq txt (strcat "TP" (itoa (setq p (fix (vlax-curve-getParamAtPoint en e)))) " - TP" (itoa (1+ p)) "\\PCS-" (substr "00" 1 (if (>= 2 (strlen (setq m (itoa (setq n (1+ n)))))) (- 2 (strlen m)) 0)) m "/" (strcase (setq l (last (assoc e ptslay)))) "\\PCH." (rtos (setq s (vlax-curve-getDistAtPoint en e)) 2 2) "m" )) (entmake (list (cons 0 "LINE") (cons 10 e) (cons 11 (list (car e) y 0.)) (cons 8 "TEXT COVER") (cons 62 210) (cons 210 '(0. 0. 1.)) )) (entmake (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 8 "TEXT COVER") (cons 10 (list (car e) y 0.)) (cons 40 2); Text height (cons 50 (* 0.5 pi)) (cons 1 txt) (cons 71 4) (cons 62 1) (cons 63 2) (cons 90 1) )) (princ (strcat "\n" l "," (rtos (car e) 2 3) "," (rtos (cadr e) 2 3) "," "0" "," ; Elevation. To omit type a semicolon in front of the line, or erase the line. (rtos s 2 3) "," "TP" (itoa p) " - TP" (itoa (1+ p)) )) ) (princ "\nWrong selection.")) (terpri)(terpri) (princ) )
Sir, the lisp in some Polyline does not hold. I think it will be nice intersection rather apparent intersection.
@Anonymous wrote:
Sir, the lisp in some Polyline does not hold. I think it will be nice intersection rather apparent intersection.
You're thinking about it right...
But I think - and I could be wrong because I don't know about ActiveX much - there is no 'apparent intersection' method. So the solution is up to you - make these apparent intersection real, not necessary on current file. Take care of elevation.
btw As I see my routine from a time distance.... you might change (initget 0) to (initget 1) everywhere you find it. It should prevent the user from responding only Enter. (initget 0) does nothing.
Can't find what you're looking for? Ask the community or share your knowledge.