show length\tag label of polyline

show length\tag label of polyline

Anonymous
Not applicable
4,814 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,815 Views
35 Replies
Replies (35)
Message 21 of 36

Anonymous
Not applicable

doesnt work

see the video capture 

0 Likes
Message 22 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:

doesnt work

see the video capture 


You should set ATTREQ to 0

 

 

0 Likes
Message 23 of 36

Anonymous
Not applicable

im doing something wrong or what?

not working 

see the video capture 

0 Likes
Message 24 of 36

hak_vz
Advisor
Advisor

I've changed the code  at #19  so try again.

 

 

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 25 of 36

Anonymous
Not applicable

Command: PIPE_LENGHT
Vertical rise to add to pipe length [0]>
Select pipe >
Pick water tag insertion point >
Tag number >6
6
63

but the tag is still showing X

 

edenbVX682_0-1623414650285.png

 

0 Likes
Message 26 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:

im doing something wrong or what?

not working 

see the video capture 


You are not doing anything wrong @Anonymous ,  Similar to your posted drawing sample, code looks  Lwpolylines under "water" layer.  I posted a question on my last posts, please reply first  instead of posting "not working" to each and every contributions from forum members. 

 

Are you wanting a program to collect the length of one single polyline or a bunch of them?

Are you going to use this from a blank with no existing tags ?

Which tags will the user use if prompted to select a polyline? The polylines are all in one layer ("water") but with different colors, one can only assume blue is cold and red is hot and the dasddot is the main line.

Why are you using a factor of 0.01  instead of the actual length ( 1429.00 as 14.00 )?

 

None of these are clear on your posts from the get-go

 

 

 

 

0 Likes
Message 27 of 36

Anonymous
Not applicable

I'm sorry
I'll try to explain myself better
I'm working for a plumbing sub contractor which fabricate water pipe (only PEX pipes) for residence apartments.

edenbVX682_0-1623415231945.jpeg

 

each pipe should get his tag number and length (integer number + 1.5 meter for the rise into the wall)

then all the information get into table of material cut pipe

the worker in the manufacturer get this table and know how much to cut for each pipe 

0 Likes
Message 28 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:

....each pipe should get his tag number and length (integer number + 1.5 meter for the rise into the wall)

then all the information get into table of material cut pipe

the worker in the manufacturer get this table and know how much to cut for each pipe 


  1. For the vertical riser, will it be always 1.5 ?  
  2. The ""MAIN SUPPLY TAG" and "WATER HEATER TAG" only have prompts for Length?  and a fix number for the TAG. Is that by design or are you also wanting to prompt the user for "No." [ TAG ] ?
  3. For all tags, the pipe is 16, 25 and 32, Will this be changing dependding on the design? or will it remain constant regardless?

There will two versions for this exercise, one with existing tags [ we can even use fields here if the riser height will indeed remain as 1.5 , then we may not need this option]  and the other is prompting the user to insert a tag.

 

Note: the water tag block is just right (scale-wise and insertion point), the other two are not. Suggest to make these consistent.

 

Also. you still need to reply on this 

Are you wanting a program to collect the length of one single polyline or a bunch of them?

Meaning one single polyline per tag?

 

HTH

 

Now, after all the tagging you still need to create a table to be pass to the manufacturer, do you need help with that too? what will it look like? 

 

 

0 Likes
Message 29 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 'attreq 1)
(setvar 'cmdecho 0)

(while (setq l(get_length (pick_line)))
(if (and l) (setq l (* 0.01 l)))
(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)
)

 

I hope that now it'll work ok. Problem was that sys variable attreq was set 0 and in that case blocks is inserted with default value that are in this case empty strings so entered values didn't work.

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 30 of 36

Anonymous
Not applicable
1. yes - 1.5, keep it changeable because sometimes is 1.5 and sometimes is 1500.. it's deepened on the drawing scale
2. MAIN SUPPLY TAG and WATER HEATER TAG have only length because the tag is permanent
3. remain constant regardless
program to collect the length of one single polyline
the tags scale is not bothering me so you can leave it as is.
the table is create in excel - inserting the values manually- there should be a way to export the data to excel.
0 Likes
Message 31 of 36

pbejse
Mentor
Mentor

@hak_vz wrote:

 

I hope that now it'll work ok. Problem was that sys variable attreq was set 0 and in that case blocks is inserted with default value that are in this case empty strings so entered values didn't work.


Oh yeah, that is true, 😊. Sorry about that, i really meant ATTDIA

Now if i do need to use insert , i set Attreq to 0, so i can use entlast to collect and modify the values. 

 

I rarely use the native command "insert" with attributes as there are too many variables to check. [scale/units/ attritbute settings... ]

 

Good catch though @hak_vz 

 

 

Message 32 of 36

hak_vz
Advisor
Advisor

@Anonymous

the table is create in excel - inserting the values manually- there should be a way to export the data to excel.

 

This can be easily done using autolisp. After you place all needed tags separate function can collect blocks of same type and entered values and export it to .csv or directly to Excel.

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 33 of 36

pbejse
Mentor
Mentor
Accepted solution

 

 

(defun c:WTG ( / _pline _Tag  attbv lenTag nosTag len bf)
;;;	pBe June 2021	;;;
(setq blk  "WATER TAG")
(setq riser (cond
    ((getreal (strcat "\nEnter vertical riser height <" (rtos (setq riser
              (cond ( riser ) ( 1.50 )) ) 2 2
          )  ">: " )))     
    ( riser )))
 
(setq _tagNos (cond
    ((getint (strcat "\nEnter TAG number <"
		     (itoa (setq _tagNos (cond ( _tagNos ) ( 1 ))))
          ">: " )))        
    ( _tagNos )))
 
(prompt "\nSelect Polyline") 
(while
   (and
        (setq bf (tblsearch "BLOCK" blk))
	(setq _pline (ssget "_+.:S:E" '((0 . "LWPOLYLINE"))))
	(setq ipt (getpoint "\nSpecify insertion point"))
	)
	(setq len (rtos (*
			  (vlax-get (vlax-ename->vla-object (ssname _pline 0)) 'Length) 0.01) 2 0))
	(setq attb (vlax-invoke (vlax-get (vla-get-ActiveLayout
	                               (vla-get-activedocument
	                                     (vlax-get-acad-object)))
	                         'Block) 'InsertBlock ipt  blk 1 1 1 0))
	(setq  attbv (mapcar '(lambda (at) (list (Vla-get-tagstring at) at))
		  (vlax-invoke  attb 'GetAttributes
		  )
		)
	)
	    (princ (strcat "\tWater pipe length = " (setq len (rtos (+ (atoi len) riser) 2 1))
			   "\tTag number: " (itoa _tagNos)))
	    (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))
			)
	      )
	    (setq _tagNos (1+  _tagNos))
	    )
 (print
   (cond
     ((null bf) "Block not found")
     ((null _pline)"Invalid or null selection")
     ((null ipt) "Invalid or null insertion point"))
   )
  (princ)
  )

 

 

Command: WTG
Enter vertical riser height <1.5>:
Enter TAG number <1>:
Select Polyline
Specify insertion point Water pipe length = 17.5 Tag number: 1
Specify insertion point Water pipe length = 18.5 Tag number: 2

 

HTH

 

0 Likes
Message 34 of 36

Anonymous
Not applicable
PERFECT! it's working like a charm!
0 Likes
Message 35 of 36

pbejse
Mentor
Mentor

@Anonymous wrote:
PERFECT! it's working like a charm!

Great, Now I can get this off my head. 

 

Cheers

beer.gif

0 Likes
Message 36 of 36

Sea-Haven
Mentor
Mentor

"it's deepened on the drawing scale" so ask is the dwg in mm or metres what do you work in, which one ? The accuracy is still there 12.015 or 12015.

0 Likes