Jump to content

Help modify lisp - align text & flow direction


datalife

Recommended Posts

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

Link to comment
Share on other sites

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 by CAD89
Completion of post
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by pBe
Quick Fix
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by pBe
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...