Hello Everyone 🙂
I found this very useful code (below) at the swamp (credit to the guy who wrote it.....many thanks!). The routine will tag conduits by placing mleader which works perfect. The only problem is it always place the tag at 0 elevation. It would be nice if it sticks to the same elevation I picked. Please help. Thanks in advance 🙂
(defun c:cndtag ( / CNDEnt CNDObj PickPoint TagPoint CNDSize CNDSystem CNDTag) (vl-load-com) (setq CNDEnt (entsel "\nSelect the conduit to tag... ") CNDObj (vlax-ename->vla-object (car CNDEnt)) PickPoint (cadr CNDEnt) TagPoint (getpoint PickPoint "\nPosition of conduit tag... ") ) (setq CNDSize (substr (vlax-get-property CNDObj "SizeName") 1 4)) (cond ((= (substr CNDSize 2 3) ".00")(setq CNDSize (substr CNDSize 1 1))) ((= (substr CNDSize 2 3) ".25")(setq CNDSize (strcat (substr CNDSize 1 1) " 1/4"))) ((= (substr CNDSize 2 3) ".50")(setq CNDSize (strcat (substr CNDSize 1 1) " 1/2"))) ((= (substr CNDSize 2 3) ".75")(setq CNDSize (strcat (substr CNDSize 1 1) " 3/4"))) ) (if (= (substr CNDSize 1 2) "0 ") (setq CNDSize (vl-string-left-trim "0 " CNDSize)) ) (setq CNDSystem (vlax-get-property CNDObj "Description") CNDTag (strcat CNDSize "\" C, " CNDSystem) ) (command "_MLEADER" PickPoint TagPoint CNDTag)
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Is this possibly just a matter of setting "OSNAPZ" to 0?
Hi JCprog,
the returned point from 'entsel' function, is the crosshair location when you select the object, not a point from the object...
To get the point on the object you'll need to test the object points, to find the closer to the returned point, or using 'osnsp'
(setq ZPoint (osnap PickPoint "End"))
or
(setq ZPoint (osnap PickPoint "nea"))
or the necessary osnap
HTH
Henrique
@JCprog wrote:
I got this:
Command: CNDTAG
Select the conduit to tag...
Position of conduit tag... Unknown command "1/2" C, ". Press F1 for help.
nil
Looks like it still looking for the "PickPoint"
Try
(defun c:cndtag (/ CNDEnt CNDObj PickPoint TagPoint CNDSize CNDSystem CNDTag) (vl-load-com) (if (and (setq CNDEnt (entsel "\nSelect the conduit to tag... ")) (setq CNDObj (vlax-ename->vla-object (car CNDEnt))) (setq PickPoint (osnap (cadr CNDEnt) "nea")) (setq TagPoint (getpoint PickPoint "\nPosition of conduit tag... ")) (vlax-property-available-p CNDObj "SizeName") (setq CNDSize (substr (vlax-get-property CNDObj "SizeName") 1 4)) (vlax-property-available-p CNDObj "Description") (setq CNDSystem (vlax-get-property CNDObj "Description")) ) (progn (cond ((= (substr CNDSize 2 3) ".00") (setq CNDSize (substr CNDSize 1 1))) ((= (substr CNDSize 2 3) ".25") (setq CNDSize (strcat (substr CNDSize 1 1) " 1/4")) ) ((= (substr CNDSize 2 3) ".50") (setq CNDSize (strcat (substr CNDSize 1 1) " 1/2")) ) ((= (substr CNDSize 2 3) ".75") (setq CNDSize (strcat (substr CNDSize 1 1) " 3/4")) ) ) (if (= (substr CNDSize 1 2) "0 ") (setq CNDSize (vl-string-left-trim "0 " CNDSize)) ) (setq CNDTag (strcat CNDSize "\" C, " CNDSystem)) (command "_MLEADER" PickPoint TagPoint CNDTag) ) ) (princ) )
Untested...
Henrique