datalife Posted January 27, 2013 Share Posted January 27, 2013 Hello all; I have download a lisp which can calculate the slope between two manhole invert level ie the upstream and downstream level. Then , the slope was indicate on the pipe line ie slope 1:xxx But something missing (I think); the text is not align to the pipeline and no flow direction indicate (ie arrow line indicate flow from upstream to downstream) Any help to modify this Lisp is appreciated. Thanks in advance mh.lsp Quote Link to comment Share on other sites More sharing options...
CAD89 Posted January 27, 2013 Share Posted January 27, 2013 (edited) Here ... try this: (defun c:mh (/ *error* acdoc ss1 ss2 l n str e) ; TharwaT 20. 04. 2011 (vl-load-com) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndoMark acdoc) (if (and (setq ss1 (entsel "\n Upstream numerical Text :")) (setq ss2 (entsel "\n Downstream numerical Text :")) (setq l (entsel "\n Select Pipe Line :")) ) (progn (setq n (- (atof (cdr (assoc 1 (entget (car ss1))))) (atof (cdr (assoc 1 (entget (car ss2))))) ) ) (setq str (/ (distance (cdr (assoc 10 (setq e (entget (car l))))) (cdr (assoc 11 e)) ) n ) [color="red"] ang (angle (cdr (assoc 10 e)) (cdr (assoc 11 e))[/color] ) ) [color="red"](if (> n 0) (setq dir (strcat "1:" (rtos str 2 3) " --->")) (setq dir (strcat "<--- 1:" (rtos str 2 3))) )[/color] (entmakex (list (cons 0 "TEXT") (cons 10 (getpoint "\n Text Location:")) (cons 40 (getvar 'textsize)) [color="red"](cons 50 ang) (cons 1 dir)[/color] ) ) ) (princ) ) (vla-EndUndoMark acdoc) (c:mh) (princ) ) The modified parts are in red! Give me some details on the arrow ... an example image would be helpful! With regards Csaba Arpad Dobai! Edited January 27, 2013 by CAD89 Completion of post Quote Link to comment Share on other sites More sharing options...
datalife Posted January 28, 2013 Author Share Posted January 28, 2013 Hello, thanks for the reply. The arrow seems NOT quite correct in some cases; as the flow should be flowing from the upstream (higher height) to downstream (lower height). See drawing example. Thanks. mh1.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted January 28, 2013 Share Posted January 28, 2013 (edited) easiest way is to use the existing texts angle [ss1] (Defun c:mh2 (/ ss1 ss2 l n str ang sp ep) (while (and (setq ss1 (entsel "\n Upstream numerical Text :")) (setq ss2 (entsel "\n Downstream numerical Text :")) (setq l (entsel "\n Select Pipe Line :")) ) (setq n (- (atof (cdr (assoc 1 [color=blue](setq ss1[/color] (entget (car ss1)))))) (atof (cdr (assoc 1 (entget (car ss2))))))) (setq str (abs (/ (distance [color=blue](setq sp[/color] (cdr (assoc 10 (setq e (entget (car l)))))) [color=blue](setq ep[/color] (cdr (assoc 11 e))) ) n))) [color=blue] (setq ang (if (> (distance (cdr (assoc 10 ss1)) ep) (distance (cdr (assoc 10 ss1)) sp)) (angle ep sp)(angle sp ep)))[/color] (entmakex (list (cons 0 "TEXT") (cons 10 (getpoint "\n Text Location:") ) (cons 40 (getvar 'textsize)) [color=blue] (cons 50 ang)[/color] (cons 1 (strcat "1:" (rtos str 2 0) "--->")) ) ) ) (princ) ) HTH Edited January 29, 2013 by pBe Quick Fix Quote Link to comment Share on other sites More sharing options...
datalife Posted January 28, 2013 Author Share Posted January 28, 2013 Hello pBE, Not quite right, the "arrow" showing the flow is not parallel to the pipeline; make it the annotation confusing. See the example of drawings i attached. Further help is very much grateful. Thanks mhdirn.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted January 28, 2013 Share Posted January 28, 2013 (edited) i didn't actually see your drawing sample, i based my suggestion solely on the code you posted. If the attached file is 2010 version or higher i wont be able to view it. Anyhow.... Somebody will come along and "fix" it for you. Cheers Edited January 29, 2013 by pBe Quote Link to comment Share on other sites More sharing options...
pBe Posted January 29, 2013 Share Posted January 29, 2013 Quick fix for you [/b] I had one of my buddies to convert the file to a lower version HTH Quote Link to comment Share on other sites More sharing options...
datalife Posted January 29, 2013 Author Share Posted January 29, 2013 It is OK for me at a lower version; so pBe........... can you help? Quote Link to comment Share on other sites More sharing options...
pBe Posted January 29, 2013 Share Posted January 29, 2013 It is OK for me at a lower version;so pBe........... can you help? I updated the code on my previous post [#4] Quote Link to comment Share on other sites More sharing options...
datalife Posted January 29, 2013 Author Share Posted January 29, 2013 Oh......... I still can't get the flow direction right????? Quote Link to comment Share on other sites More sharing options...
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.