@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"