datalife 发表于 2022-7-6 07:01:21

Help modify lisp - align text

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

CAD89 发表于 2022-7-6 07:12:03

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   ) ang (angle (cdr (assoc 10 e))          (cdr (assoc 11 e))   )      )   (if (> n 0) (setq dir (strcat "1:" (rtos str 2 3) " --->")) (setq dir (strcat "

datalife 发表于 2022-7-6 07:18:31

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

pBe 发表于 2022-7-6 07:23:16

easiest way is to use the existing texts angle
 

(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 (setq ss1 (entget (car ss1))))))       (atof (cdr (assoc 1 (entget (car ss2)))))))   (setqstr (abs (/ (distance   (setq sp (cdr (assoc 10 (setq e (entget (car l))))))   (setq ep (cdr (assoc 11 e)))   )n))) (setq ang (if (> (distance (cdr (assoc 10 ss1)) ep)      (distance (cdr (assoc 10 ss1)) sp)) (angle ep sp)(angle sp ep)))   (entmakex   (list (cons 0 "TEXT")    (cons 10   (getpoint "\n Text Location:")    )    (cons 40 (getvar 'textsize))    (cons 50 ang)    (cons 1 (strcat "1:" (rtos str 2 0) "--->"))   )   ) ) (princ))
 
HTH

datalife 发表于 2022-7-6 07:30:54

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

pBe 发表于 2022-7-6 07:40:01

i didn't actually see your drawing sample, i based my suggestionsolely 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

pBe 发表于 2022-7-6 07:42:53

Quick fix for you
 
I had one of my buddies to convert the file to a lower version
 
HTH

datalife 发表于 2022-7-6 07:48:32

It is OK for me at a lower version;
so pBe........... can you help?

pBe 发表于 2022-7-6 08:00:19

 
I updated the code on my previous post [#4]

datalife 发表于 2022-7-6 08:06:25

Oh......... I still can't get the flow
direction right?????
页: [1]
查看完整版本: Help modify lisp - align text