CivilTechSource Posted November 2 Posted November 2 Hi Everyone! Very new to this forum and to the AutoLisp (Although some minimal understanding of coding). I work for Civil Engineering firm and one of constant routines is carry out pipe clash detection for drainage. I did automate the process by using an excel spreadsheet to do all the checks for you but I still feel AutoLisp will save even more time. I broke down the code to the below steps: - Request from user minimum clearance (eg. 100mm) - Prompt user to select two lines/polylines (Each line.polyline represents a pipe) - Check if lines intersect - If lines intersect then request/Calculate the following variables Pipe 1: Upstream Invert Level - User Input (UI) Downstream Invert Level - UI Pipe Diameter - UI Intersection Length with other Pipe (Line/polyline)- Calculated Slope - Calculated Slope = Length/(Upstream Invert Level - Downstream Invert Level) Intersection Invert Level - Calculated Intersection Invert Level = Upstream Invert Level - (Intersection Length/ Slope) Crown Level - Calculated Crown Level = Intersection Invert Level + Diameter The Lisp will have to calculate the same for pipe 2. - The next step will be to run clash check 1. Compare the intersection Invert level from both pipes and find which pipe is the highest 2. Then subtract from the highest pipe invert level against the lower pipe invert level plus the diameter. 3. Check if the distance between the pipes to establish state: - If distance less than 0 then its a - clash - if distance less than clearance - very close - if distance greater than clearance - No Clash - Draw circle a circle based on the status of the pipes - Green if clear (no clash), orange if close, red if clash **Side bonus if the lisp can either: a) Allow the user to select an Mtext which contains the value of IL or B) The lisp searches for an Mtext near the pipe (on a specified layer - maybe prompt the user to select which layer is the mtext in as there are two types of pipes storm & foul). I am happy to appoint the right person to develop this lisp in exchange for a fee if required. However my preference is to be pointed out to the right sources/reading materials that can help me achieve this. Thank you for taking the time reading this. Quote
BIGAL Posted November 3 Posted November 3 (edited) Welcome aboard Have a look at this. Whilst I commercially write code I would look at this as money better spent as it has so much more, includes surfaces, road, drainage, sewer and more. I am a civil engineer working with Pc based software since 1980's This is a full demonstration of pipe network design, the pipe clash detection is at the 41 minute mark. https://www.google.com/search?q=civil+site+design+pipe+clash&sca_esv=f5375ae535b801fb&sxsrf=ADLYWIJr68ulCkDgsADBN0wgz-i38TvIRw%3A1730672990550&source=hp&ei=XvknZ5TAH6WMseMPr6iluA4&iflsig=AL9hbdgAAAAAZygHbsl16NgegCtQPahhlgceo_wof6U6&ved=0ahUKEwiU58mmm8GJAxUlRmwGHS9UCecQ4dUDCBg&uact=5&oq=civil+site+design+pipe+clash&gs_lp=Egdnd3Mtd2l6IhxjaXZpbCBzaXRlIGRlc2lnbiBwaXBlIGNsYXNoMgUQIRigATIFECEYoAEyBRAhGKABSNFQULQDWNhFcAJ4AJABAJgBjgKgAZktqgEHMC4xNS4xNLgBA8gBAPgBAZgCH6ACnS6oAgrCAgcQIxgnGOoCwgINEC4YxwEYJxjqAhivAcICBxAuGCcY6gLCAgQQIxgnwgIIEAAYgAQYsQPCAg4QLhiABBixAxjRAxjHAcICERAuGIAEGLEDGNEDGIMBGMcBwgILEAAYgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICDhAuGIAEGLEDGIMBGNQCwgIFEC4YgATCAgUQABiABMICDhAuGIAEGLEDGMcBGK8BwgIREC4YgAQYsQMYgwEYxwEYrwHCAgsQLhiABBixAxiDAcICCBAuGIAEGLEDwgILEC4YgAQYxwEYrwHCAgsQLhiABBixAxjUAsICBhAAGBYYHsICDBAuGNEDGBYYxwEYHsICCxAAGIAEGIYDGIoFwgIIEAAYgAQYogTCAggQABiiBBiJBcICBRAhGJ8FwgIHECEYoAEYCpgDCpIHBzIuMTUuMTSgB8POAQ&sclient=gws-wiz#fpstate=ive&vld=cid:1665ccf8,vid:UXyKkYI8WM4,st:69 Where are you in the world ? Edited November 3 by BIGAL Quote
CivilTechSource Posted November 4 Author Posted November 4 Hi Bigal, Thanks for the reply. I am aware there are other software that can do this. However, we do not tend to model private (housing) drainage and we just draw them in 2d hence the need for the clash check analysis. Based in UK, wbu? Quote
hosneyalaa Posted November 4 Posted November 4 (edited) You need Program Autodesk Navisworks 0r program civil 3d Manage Can you attached example drawing Edited November 4 by hosneyalaa Quote
BIGAL Posted November 4 Posted November 4 You will need to work in some form of 3d if you want a clash detect, even a line must be in 3D, as each end would have different Z's, that constitutes 3D. I drew 2 line with same Z's so they did touch. (setq intpt1 (vlax-invoke obj2 'intersectWith obj acextendnone)) (48.3996714787087 22.018104682769 9.99999999999999) ; this was a perfect example where two 3d lines do touch : : (setq intpt1 (vlax-invoke obj2 'intersectWith obj acextendnone)) ; changed 1 end of same lines and now does not work. nil One thing you can do is trim two 3d lines and so get 2 new Z values for end of line. Then say use some form of comparison of the z values. A less than & greater than maybe. Sorry no code. Using trim common point, Z=10 line 1 Z=9.5 line 2 Quote
CivilTechSource Posted November 5 Author Posted November 5 Hi Bigal, I know if 3d was the case then it would be very smart to trim them and find the point. But unfortunately its 2d lines and the user will enter the start and end z value manually. I started writing the code but I am having trouble calculating the intersection length. Not sure why it does not work. If you can assist with the below that would be perfect and will just keep building on it. (defun c:intersectLines (/ p1 p2 p3 p4 intpt) (setq pipeclearance (getpoint "\nPlease set pipe clearance: ")) (setq p1 (getpoint "\nSelect the start point of the Pipe 1: ")) (setq p2 (getpoint "\nSelect the end point of the Pipe 1: ")) (setq p1d (getint "\nSpecify Diameter Pipe 1: ")) (setq p3 (getpoint "\nSelect the start point of the Pipe 2: ")) (setq p4 (getpoint "\nSelect the end point of the Pipe 2: ")) (setq p2d (getint "\nSpecify Diameter Pipe 2: ")) (setq intpt (inters p1 p2 p3 p4)) ;Calculate Intersection Point ;Check if lines intersect. (if intpt (progn (command "-point" intpt "") (princ "\nIntersection point: ") (princ intpt) ) (princ "\nLines do not intersect.") ) (setq dx1 (- (cdr p2) (cdr p1))) ;Problem during debugging happens on this line. (setq dy1 (- (car p2) (car p1))) (setq IntersectionDistance1 (sqrt (+ (* dx1 dx1) (* dy1 dy1)))) (setq dx2 (- (cdr p3) (cdr p4))) (setq dy2 (- (car p3) (car p4))) (setq IntersectionDistance2 (sqrt (+ (* dx2 dx2) (* dy2 dy2)))) (prompt "\nDistance from p1 to intersection point is: ") (princ IntersectionDistance1) Quote
BIGAL Posted November 5 Posted November 5 Just edit the values of the line ends and it becomes a 3dline then trim works. It is easy to work out which end you have picked as you can say use "Pick downstream end" you compare the pick point to the two end points and swap if necessary. As I would use civil software I am not going to spend a lot of time but here is a start for correct ends. (setq ent (entsel "\nPick line near downstream end ")) (setq pt (cadr ent)) (setq obj (vlax-ename->vla-object (car ent))) (setq start (vlax-curve-getstartPoint obj)) (setq end (vlax-curve-getEndPoint obj)) (setq d1 (distance pt start)) (setq d2 (distance pt end)) (if (> d1 d2) (progn (setq tmp end) (setq end start) (setq start tmp) ) ) Quote
CivilTechSource Posted November 6 Author Posted November 6 Hi Bigal, Thank you for your time! I do also prefer using drainage software to do this. I think I have a working lisp! Any comments / Feedback would be great! Thank you again! ;Produced by Civil Tech Source ;Version 1.0 (defun c:CCC () ;----Get User Input (setq Clearance 0.15) (setq p1 (getpoint "\nSelect the start point of the Pipe 1: ")) (setq USIL1 (getreal "\nUpstream Invert Level of Pipe 1: ")) (setq p2 (getpoint "\nSelect the end point of the Pipe 1: ")) (setq DSIL1 (getreal "\nDownstream Invert Level of Pipe 1: ")) (setq Diameter1 (getreal "\nSpecify Diameter of Pipe 1: ")) (setq p3 (getpoint "\nSelect the start point of the Pipe 2: ")) (setq USIL2 (getreal "\nUpstream Invert Level of Pipe 1: ")) (setq p4 (getpoint "\nSelect the end point of the Pipe 2: ")) (setq DSIL2 (getreal "\nDownstream Invert Level of Pipe 1: ")) (setq Diameter2 (getreal "\nSpecify Diameter of Pipe 2: ")) ;---- ;----Calculate Lengths & Slopes (princ "\nCalculating Pipe Lengths & Slopes") (setq Pipe1Length (distance p1 p2)) (setq Pipe2Length (distance p3 p4)) (princ "\nPipe 1 Lenght: ") (princ Pipe1Length) (princ "\nPipe 2 Lenght: ") (princ Pipe2Length) (setq Slope1 (/ Pipe1Length (- USIL1 DSIL1))) (setq Slope2 (/ Pipe2Length (- USIL2 DSIL2))) (princ "\nSlope for Pipe 1 is : 1 in ") (princ Slope1) (princ "\nSlope for Pipe 2 is : 1 in ") (princ Slope2) ;---- ;----Calculate Intersection Point (princ "\nCalculating Intersection Point") (setq intpt (inters p1 p2 p3 p4)) (if intpt (progn (command "-point" intpt "") (princ "\nIntersection point: ") (princ intpt) ) (princ "\nLines do not intersect.") ) ;---- ;----Calculate Distance & Invert Level from Upstream Point to Intersection Point ;----Distance (setq Pipe1Distance (distance p1 intpt)) (setq Pipe2Distance (distance p3 intpt)) (princ "\nPipe 1 Intersection length : ") (princ Pipe1Distance) (princ "\nPipe 2 Intersection length : ") (princ Pipe2Distance) ;----Intersection Level (setq IntIL1 (- USIL1 (/ Pipe1Distance Slope1))) (princ "\nPipe 1 Intersection Invert Level: ") (princ IntIL1) (setq IntIL2 (- USIL2 (/ Pipe2Distance Slope2))) (princ "\nPipe 2 Intersection Invert Level: ") (princ IntIL2) (princ "") ;---- ;----Calculate Crown Levels (setq Crown1 (+ IntIL1 (/ Diameter1 1000))) (setq Crown2 (+ IntIL2 (/ Diameter2 1000))) (princ "\nPipe 1 Crown Level: ") (princ Crown1) (princ "\nPipe 2 Crown Level: ") (princ Crown2) (princ "") ;---- ;----Calculate Which Pipe is at Higher Level using Invert Level to Calculate Clearance (if (> IntIL1 IntIL2) (setq PipeClearance (- IntIL1 Crown2)) (setq PipeClearance (- Intil2 Crown1)) ) (princ "\nClearance between Pipes is:") (princ PipeClearance) (princ "") ;---- ;----Check Clearance (if (< PipeClearance 0) (princ "Clash!")(setq i 0) (if (and (> PipeClearance 0) (< PipeClearance Clearance)) (princ "Close")(setq i 1) (princ "Clear")(setq i 2) ) ) ;---- ) Quote
BIGAL Posted November 6 Posted November 6 You can use the pick end rather than the pick 2 points, another I would use (alert "There is a clash ") its more hit you in the face than using (princ. Your welcome to use my Multi getvals.lsp for the input of the 4 Invert levels. Can see what your inputing. Multi GETVALS.lsp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.