show length\tag label of polyline

show length\tag label of polyline

Anonymous
Not applicable
4,803 Views
35 Replies
Message 1 of 36

show length\tag label of polyline

Anonymous
Not applicable

im drawing water plan with polyline 

each pipe (PEX) get is own polyline 

im looking for a lisp or something else that will show the total length of each polyline +1.5 meter (for the vertical rise)

it is possible? 

0 Likes
Accepted solutions (1)
4,804 Views
35 Replies
Replies (35)
Message 2 of 36

hak_vz
Advisor
Advisor

@Anonymous 

Always add sample drawing and lots of details about how you want your problem solved.

In this case how you want pipes lengths to be shown i.e written over a pipe, alert box or else?

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 36

hak_vz
Advisor
Advisor

Since you didn't answered on time, here is something to play with.

 

 

(defun c:pipe_lenght ( / vertical_rise get_length pick_line e l *error*)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(princ)
)
(setq vertical_rise (getreal "\nVertical rise to add to pipe length [0]> "))
(if (not vertical_rise) (setq vertical_rise 0))
(defun get_length (e)
(cond ((and e (= (type e) 'ENAME)) (setq e (vlax-ename->vla-object e))))
(cond ((and e (vlax-property-available-p e 'Length)) (vlax-get e 'Length)))
)

(defun pick_line( / ss)
	(setq e (car(entsel "\nSelect pipe >")))
	(if (and (not e) (= (getvar 'Errno) 7)) (pick_line) e)
)

(while (setq l (get_length (pick_line))) (princ (strcat "\n" (rtos (+ l vertical_rise) 2 2))))
(princ)
)

 

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 36

Kent1Cooper
Consultant
Consultant

As a start, >LabelLengths.lsp< may do what you want.  If it does for the actual lengths, it can easily be modified to add a fudge factor.

Kent Cooper, AIA
0 Likes
Message 5 of 36

3wood
Advisor
Advisor

You can do it in 2 steps.

Step 1, add length tag to polylines. You can try ADDLINES.

Step 2, modify the tags in  Step 1 and add 1.5m to each tag with ALTEXT.

 

0 Likes
Message 6 of 36

Anonymous
Not applicable

sorry for the delay
I want alert box
I need the length to be an Integer or number and a half (exp- 1m, 1.5m, 2m, 2.5m etc...)

0 Likes
Message 7 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:

I need the length to be an Integer or number and a half (exp- 1m, 1.5m, 2m, 2.5m etc...)


is the tag connected to the polyline in anyway?

 

0 Likes
Message 8 of 36

Anonymous
Not applicable
it's not necessary but it will be nice.
0 Likes
Message 9 of 36

hak_vz
Advisor
Advisor

@Anonymous wrote:

sorry for the delay
I want alert box
I need the length to be an Integer or number and a half (exp- 1m, 1.5m, 2m, 2.5m etc...)


(defun c:pipe_lenght ( / vertical_rise get_length pick_line a b d e l *error*)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(princ)
)
(setq vertical_rise (getreal "\nVertical rise to add to pipe length [0]> "))
(if (not vertical_rise) (setq vertical_rise 0))
(defun get_length (e)
(cond ((and e (= (type e) 'ENAME)) (setq e (vlax-ename->vla-object e))))
(cond ((and e (vlax-property-available-p e 'Length)) (vlax-get e 'Length)))
)

(defun pick_line( / ss)
	(setq e (car(entsel "\nSelect pipe >")))
	(if (and (not e) (= (getvar 'Errno) 7)) (pick_line) e)
)

(while (setq l (get_length (pick_line)))
(setq d (atof(rtos (+ l vertical_rise) 2 2)))
(setq a (fix d) b (atoi(rtos (* 100 (- d a)) 2 1))) 
(cond
	((<= b 25) (setq b 0))
	((and (> b 25)(<= b 75)) (setq b 5))
	((> b 75) (setq b 10))
)
(alert (strcat "\nPipe length = " (rtos (+ a (/ b 10.0)) 2 1)))
)
(prin

 

@Anonymous  I hope this is what you asked for. If it works for you, accept this tread as a solution.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 10 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:
it's not necessary but it will be nice.

I'm not suggesting anything @Anonymous , its actually a question for you as per you request below.

 

show length\tag label of polyline

I assumed the "water tag" block is the tag, the existing blocks already shows a length and a tag name. 

Are you wanting to get the total of  all same tag values? which in effect does not involve selecting any of the polylines  under "water" layer?

 

or are you  wanting the user to select a polyline then assign the values to the "water tag" block?

 

Please post an example of the result. 

 

 

 

 

0 Likes
Message 11 of 36

Anonymous
Not applicable
i got this error when loading the lisp

Command: _appload pipelength.lsp successfully loaded.
Command: ; error: malformed list on input
0 Likes
Message 12 of 36

hak_vz
Advisor
Advisor

Try now

 

(defun c:pipe_lenght ( / vertical_rise get_length pick_line a b d e l *error*)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(princ)
)
(setq vertical_rise (getreal "\nVertical rise to add to pipe length [0]> "))
(if (not vertical_rise) (setq vertical_rise 0))
(defun get_length (e)
(cond ((and e (= (type e) 'ENAME)) (setq e (vlax-ename->vla-object e))))
(cond ((and e (vlax-property-available-p e 'Length)) (vlax-get e 'Length)))
)

(defun pick_line( / ss)
	(setq e (car(entsel "\nSelect pipe >")))
	(if (and (not e) (= (getvar 'Errno) 7)) (pick_line))
	e
)

(while (setq l (get_length (pick_line)))
(setq d (atof(rtos (+ l vertical_rise) 2 2)))
(setq a (fix d) b (atoi(rtos (* 100 (- d a)) 2 1))) 
(cond
	((<= b 25) (setq b 0))
	((and (> b 25)(<= b 75)) (setq b 5))
	((> b 75) (setq b 10))
)
(alert (strcat "\nPipe length = " (rtos (+ a (/ b 10.0)) 2 1)))
)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 13 of 36

Anonymous
Not applicable
I did put the length and the tag number manually in the water tag

each polyline represents pipe segment (hot/cold)
I need to know the length of each pipe - for example the length of the cold water pipe from the water cabinet to the shower is 8 meter.
0 Likes
Message 14 of 36

Anonymous
Not applicable
that work!
now how can i take this lisp and make him put the result into water tag block?
0 Likes
Message 15 of 36

hak_vz
Advisor
Advisor
(defun c:pipe_lenght ( / vertical_rise get_length pick_line a b d e l *error*)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(princ)
)
(setq vertical_rise (getreal "\nVertical rise to add to pipe length [0]> "))
(if (not vertical_rise) (setq vertical_rise 0))
(defun get_length (e)
(cond ((and e (= (type e) 'ENAME)) (setq e (vlax-ename->vla-object e))))
(cond ((and e (vlax-property-available-p e 'Length)) (vlax-get e 'Length)))
)

(defun pick_line( / ss)
	(setq e (car(entsel "\nSelect pipe >")))
	(if (and (not e) (= (getvar 'Errno) 7)) (pick_line))
	e
)

(while (setq l (* 0.01 (get_length (pick_line))))
(setq d (atof(rtos (+ l vertical_rise) 2 2)))
(setq a (fix d) b (atoi(rtos (* 100 (- d a)) 2 1))) 
(cond
	((<= b 25) (setq b 0))
	((and (> b 25)(<= b 75)) (setq b 5))
	((> b 75) (setq b 10))
)
(alert (strcat "\nPipe length = " (rtos (+ a (/ b 10.0)) 2 1)))
(command "_.insert" "water tag")
)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 16 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:
that work!
now how can i take this lisp and make him put the result into water tag block?

That is exactly what i'm referring to @Anonymous 

(defun c:Demo ( /  _pline _Tag  attbv lenTag nosTag len)
(setq riser (cond
    ((getreal (strcat "\nChoose a Number <" (rtos (setq riser
              (cond ( riser ) ( 2.50 )) ) 2 2
          )  ">: " )))     
    ( riser )))
  
(setq _tagNos (cond
    ((getint (strcat "\nEnter TAG number <"
		     (itoa (setq _tagNos (cond ( _tagNos ) ( 1 ))))
          ">: " )))        
    ( _tagNos )))
  
(if
	(and
	  (setq _pline (ssget "_+.:S:E" '((0 . "LWPOLYLINE")(8 . "water"))))
	  (setq _Tag (ssget "_+.:S:E" '((0 . "INSERT")(2 . "main supply tag,water*tag"))))
	  )
  
	  (progn
	      (setq len (rtos
			  (* (vlax-get (vlax-ename->vla-object (ssname _pline 0)) 'Length) 0.01) 2 0))
	      (setq  attbv	(mapcar
			  '(lambda (at)
			     (list (Vla-get-tagstring at) at)
			   )
			  (vlax-invoke
			    (vlax-ename->vla-object (ssname _Tag 0)) 'GetAttributes
			  )
			)
		)
	    (alert (strcat "\nWater pipe length = " (setq len (rtos (+ (atoi len) riser) 2 1))))
	    (cond
	      ((null attbv)	)
	      ((and
			(setq lenTag (assoc "LENGTH" attbv))
			(setq nosTag (assoc "NO." attbv)))
			(vla-put-textstring (cadr lenTag) len)
	                (vla-put-textstring (cadr nosTag)(itoa _tagNos))
			)
	      ( lenTag
	      	(vla-put-textstring (cadr lenTag) len )
		
		)
	      )
	    (setq _tagNos (1+  _tagNos))
	    )
  )
  (princ)
  )

HTH

0 Likes
Message 17 of 36

Anonymous
Not applicable
why it doesn't show the tag at the end?

Command: DEMO
Choose a Number <1>:
Enter TAG number <1>: 5
Select objects:
Command:
0 Likes
Message 18 of 36

Anonymous
Not applicable

edenbVX682_0-1623410668540.png

still need to write manually the length 

can't it take the length from the command and put it automatically in this window 

 

 


Command: PIPE_LENGHT
Vertical rise to add to pipe length [0]> 1500
Select pipe >_.insert Enter block name or [?] <A$Cf59cb81f>: water tag
Units: Unitless Conversion: 1.0
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate/Explode/REpeat]:
Error: bad argument type: numberp: nilSpecify insertion point or [Basepoint/Scale/X/Y/Z/Rotate/Explode/REpeat]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
Enter Y scale factor <use X scale factor>: 1
Specify rotation angle <0>:

0 Likes
Message 19 of 36

hak_vz
Advisor
Advisor

 

 

(defun c:pipe_lenght ( / vertical_rise get_length pick_line a b d e l *error*)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(setvar 'attdia 1)
	(setvar 'cmdecho 0)
	(princ)
)
(setq vertical_rise (getreal "\nVertical rise to add to pipe length [0]> "))
(if (not vertical_rise) (setq vertical_rise 0))
(defun get_length (e)
(cond ((and e (= (type e) 'ENAME)) (setq e (vlax-ename->vla-object e))))
(cond ((and e (vlax-property-available-p e 'Length)) (vlax-get e 'Length)))
)

(defun pick_line( / ss)
	(setq e (car(entsel "\nSelect pipe >")))
	(if (and (not e) (= (getvar 'Errno) 7)) (pick_line))
	e
)
(setvar 'attdia 0)
(setvar 'cmdecho 0)

(while (setq l (* 0.01 (get_length (pick_line))))
(setq d (atof(rtos (+ l vertical_rise) 2 2)))
(setq a (fix d) b (atoi(rtos (* 100 (- d a)) 2 1))) 
(cond
	((<= b 25) (setq b 0))
	((and (> b 25)(<= b 75)) (setq b 5))
	((> b 75) (setq b 10))
)
(setq d (atof(rtos (+ a (/ b 10.0)) 2 1)))
;(alert (strcat "\nPipe length = " d))
(setq pt (getpoint "\nPick water tag insertion point >"))
(setq no (getint "\nTag number >"))

(command "_.insert" "water tag" pt 0.1 0.1 0 no d )
)
(setvar 'attdia 1)
(setvar 'cmdecho 1)
(princ)
)

 

 

Try this version that directly places "water tag" block without showing alert. If you want to show alert then delete ;

infront (alert .....)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 20 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:
why it doesn't show the tag at the end?

Command: DEMO
Choose a Number <1>:
Enter TAG number <1>: 5
Select objects:
Command:

Its' my bad, I mislabelled the prompt. it should say

(setq riser (cond
    ((getreal (strcat "\nEnter vertical riser height <" (rtos (setq riser
              (cond ( riser ) ( 2.50 )) ) 2 2
          )  ">: " )))     
    ( riser )))

Also, there are missing prompt that the user should be able to idenftify what to select

(defun c:WaterLine( /  _pline _Tag  attbv lenTag nosTag len)
(setq riser (cond
    ((getreal (strcat "\nEnter vertical riser height <" (rtos (setq riser
              (cond ( riser ) ( 2.50 )) ) 2 2
          )  ">: " )))     
    ( riser )))
  
(setq _tagNos (cond
    ((getint (strcat "\nEnter TAG number <"
		     (itoa (setq _tagNos (cond ( _tagNos ) ( 1 ))))
          ">: " )))        
    ( _tagNos )))
  
(if
	(and
	  (princ "\nSelect Polyline")
	  (setq _pline (ssget "_+.:S:E" '((0 . "LWPOLYLINE")(8 . "water"))))
	  (princ "\nSelect tag block")
	  (setq _Tag (ssget "_+.:S:E" '((0 . "INSERT")(2 . "main supply tag,water*tag"))))
	  )
  
	  (progn
	      (setq len (rtos
			  (* (vlax-get (vlax-ename->vla-object (ssname _pline 0)) 'Length) 0.01) 2 0))
	      (setq  attbv	(mapcar
			  '(lambda (at)
			     (list (Vla-get-tagstring at) at)
			   )
			  (vlax-invoke
			    (vlax-ename->vla-object (ssname _Tag 0)) 'GetAttributes
			  )
			)
		)
	    (alert (strcat "\nWater pipe length = " (setq len (rtos (+ (atoi len) riser) 2 1))))
	    (cond
	      ((null attbv)	)
	      ((and
			(setq lenTag (assoc "LENGTH" attbv))
			(setq nosTag (assoc "NO." attbv)))
			(vla-put-textstring (cadr lenTag) len)
	                (vla-put-textstring (cadr nosTag)(itoa _tagNos))
			)
	      ( lenTag
	      	(vla-put-textstring (cadr lenTag) len )
		
		)
	      )
	    (setq _tagNos (1+  _tagNos))
	    )
  )
  (princ)
  )

How it works:

command: waterline

Enter vertical riser height <2.50>: [ either enter a new value of accept the default ]
Enter TAG number <4>:  [ either enter a new value of accept the default ]
Select Polyline <-- was mising before
Select objects:

Select tag block <-- was mising before

Now, keep in mind that on your drawing, you have 3 different tags, 

  • "water tag", <-- this has two attributes  ( "LENGTH" "NO." )
  • "water heater tag" and  "main supply tag" both has only one attribute   ( "LENGTH" )

We can modify the program to prompt the user to insert a block for a spefic tag,  will that work for you?

command: WHT for "water heater tag"

command: MST "main supply tag"

command: Waterline for "water tag"

 

 

0 Likes