Hi,
We have been using the attached lisp for a while but we have recently updated to 2014 and now it seems to not work correctly. It runs through but doesnt give the correct result.
It is used for quickly annotating the gradient along pipe runs by selecting text levels, length of run etc.
Can anyone please help!
Thanks in advance
Welcome to the Autodesk forums.
I didn't have a sample drawing to test, so unsure why your routine isn't working.
This seems to work, using Civil 3D 2014, and includes a few enhancements:
(vl-load-com) (defun c:SLABEL (/ *error* ss1 ss2 pt1 pt2 diameter material osmode acDoc layerName oLayer oText ) (defun *error* (msg) (if oText (vla-delete oText) ) (and osmode (setvar 'osmode osmode)) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (and (princ "\nSelect upper level text: ") (setq ss1 (ssget ":S:E" '((0 . "MTEXT,TEXT")))) (princ "\nSelect lower level text: ") (setq ss2 (ssget ":S:E" '((0 . "MTEXT,TEXT")))) (setq pt1 (getpoint "\nSpecify pipe start (left): ")) (not (initget 32)) (setq pt2 (getpoint pt1 "\nSpecify pipe end (right): ")) (setq diameter (getint "\nEnter pipe diameter: ")) (not (initget 1 "Clay cOncrete Plastic")) (setq material (getkword "\nEnter pipe material [Clay/cOncrete/Plastic]: " ) ) (setq osmode (getvar 'osmode)) (setvar 'osmode 0) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq oLayer (vla-add (vla-get-layers acDoc) (setq layerName "TEXT")) ) (vla-put-color oLayer acyellow) (setq oText (vla-addtext (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) (strcat "%%C" (itoa diameter) " " (if (= "cOncrete" material) "Concrete" material ) " 1:" (itoa (fix (/ 1.0 (/ (- (atof (cdr (assoc 1 (entget (ssname ss1 0)))) ) (atof (cdr (assoc 1 (entget (ssname ss2 0)))) ) ) (distance pt1 pt2) ) ) ) ) ) (vlax-3d-point '(0 0 0)) 0.3 ) ) (vla-put-alignment oText acalignmentcenter) (vla-put-layer oText layerName) (vla-put-rotation oText (angle pt1 pt2)) (vla-move oText (vla-get-textalignmentpoint oText) (vlax-3d-point (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5 0.5))) ) (setq oText (command "._move" (vlax-vla-object->ename oText) "" (vlax-get oText 'textalignmentpoint) pause ) ) ) ) (*error* nil) )
You could remove the MOVE Command call, and replace with Acet-Ss-Drag-Move if you'd prefer, but that adds another localized variable (for the implicit secondary vla-Move call).
Cheers
"How we think determines what we do, and what we do determines what we get."