tixtax Posted March 11, 2020 Share Posted March 11, 2020 Hi I need a routine which labels polyline length with this arrange: "incremental prefix" + "automatic field value of polyline length" + "meter as suffix". the output will be something like this : "R1=[100]m" i will be very thankful if you could help me Saeid Quote Link to comment Share on other sites More sharing options...
tixtax Posted March 11, 2020 Author Share Posted March 11, 2020 @Lee Mac Hello Mr. Lee Mac I've tried your very useful routine, NumInc for this problem. but i couldn't add length field to it. is it possible to do so? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 11, 2020 Share Posted March 11, 2020 This is not possible using the current version of my NumInc application, but it is certainly possible to develop a program to perform this task. Quote Link to comment Share on other sites More sharing options...
tixtax Posted March 11, 2020 Author Share Posted March 11, 2020 (edited) @Lee Mac I've got tons of these drawings to do and it is real hard to add a length field to every label manually. Sorry,but I'm new to autolisp and hours of searching, studying and trying to write a working routine to solve this problem led to nothing! Would you please help me? it will save me an incredible amount of time and i will be very grateful to you. thanks in advance Edited March 11, 2020 by tixtax Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 13, 2020 Share Posted March 13, 2020 A custom lisp will quickly label the running length along a pline, there are numerous Chainage.lsp programs out there and it would be pretty simple to change the labelling output from say CH100.0 +1+000.00 and other variations. The custom part is in the where the label is to appear. Google Chainage.lsp as first step find something close then it can probably be changed to suit. Quote Link to comment Share on other sites More sharing options...
tixtax Posted March 15, 2020 Author Share Posted March 15, 2020 Thank you for replying, Bigal. Actually I tried many chainage lisps and couldn't figure out how to modify it so that it lables polyline length with field value. I assumed this would not be a big deal. I'm totally confused and disappointed somehow. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 15, 2020 Share Posted March 15, 2020 You need to remove the word Field in what your asking for the chainage lisps write a text value of the distance from a start point. As you have only posted an image its a bit hard to post something. Post a dwg and some one will post an answer. Quote Link to comment Share on other sites More sharing options...
tixtax Posted March 15, 2020 Author Share Posted March 15, 2020 This is a sample of my drawings. all I need is to label those green polylines with this order: "an incremental prefix" + "field value of polyline length" + "a suffix". I've used Lee Mac's NumInc for incremental prefixes and added length field manually. Sample.dwg Quote Link to comment Share on other sites More sharing options...
tixtax Posted March 31, 2020 Author Share Posted March 31, 2020 Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 31, 2020 Share Posted March 31, 2020 (edited) Sorry for missing out this post! This will solve all your problems. Selection sequence will determine which polyline is first and which is last. Upon prompt on selection, you can type F and select by fence. (defun c:polyfield ( / *error* acadobj activeundo adoc alpt ang base hgt i inc midpt msp num ss str suff vln vtst vtxt) (defun *error* ( msg ) (vla-EndUndoMark adoc) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*")) (princ (strcat "Error: " msg)) ) ) (setq acadobj (vlax-get-acad-object) adoc (vla-get-ActiveDocument acadobj) msp (vla-get-ModelSpace adoc) activeundo nil) (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T)) (setq hgt 3.3 ; <--- Set text height here base (getstring T "\nSpecify prefix: ") suff (getstring T "\nSpecify suffix <m>: ") num (progn (initget 7) (getint "\nSpecify starting number: ")) inc (cond ((progn (initget 6) (getint "\nSpecify increment or <1>: "))) (1)) ss (ssget '((0 . "LINE,LWPOLYLINE"))) ) (if (eq suff "") (setq suff "m")) (if ss (progn (repeat (progn (setq i -1) (sslength ss)) (setq vln (vlax-ename->vla-object (ssname ss (setq i (1+ i)))) str (strcat base (itoa num) "=" "%<\\AcObjProp Object(%<\\_ObjId " (if (vlax-method-applicable-p (vla-get-Utility adoc) 'getobjectidstring) (vla-GetObjectIdString (vla-get-Utility adoc) vln :vlax-false) (itoa (vla-get-objectid vln)) ) ">%).Length \\f \"%lu2%pr2\">%" suff ) midpt (vlax-curve-getPointAtDist vln (* 0.5 (vla-get-Length vln))) ang (angle '(0 0 0) (vlax-curve-getFirstDeriv vln (vlax-curve-getParamAtPoint vln midpt))) ang (if (<= (* 0.5 pi) ang (* 1.5 pi)) (- ang pi) ang ) vtxt (vla-AddText msp str (setq alpt (vlax-3d-point (polar midpt (+ (* 0.5 pi) ang) hgt))) hgt) ) (vla-put-Alignment vtxt acAlignmentMiddleCenter) (vla-put-TextAlignmentPoint vtxt alpt) (vla-put-Rotation vtxt ang) (setq num (+ num inc)) ) ) ) (if activeundo nil (vla-EndUndoMark adoc)) (princ) ) Just out of curiosity, that seems to look like a riser (blue line) by which it goes to the manifolds (orange blocks) into every floor and then into every apartment (the blue blocks). I do hydraulics too so it looks super familiar to me. If that's true, that's quite the shape of the building (red polyline). It also seems like the water meters (blue blocks) are drawn on every vertex of the polyline. If that's so, this may help you: (defun c:putvalve ( / i ss) (if (setq ss (ssget '((0 . "LINE,LWPOLYLINE")))) (repeat (setq i (sslength ss)) (foreach x (vl-remove-if-not '(lambda (x) (vl-position (car x) '(10 11))) (entget (ssname ss (setq i (1- i))))) (entmake (list '(0 . "INSERT") '(100 . "AcDbEntity") '(100 . "AcDbBlockReference") '(2 . "Rayzer full") ; <--- Set block name here '(8 . "Rayzer full") ; <--- Set layer here (cons 10 (cdr x)) '(41 . 1) '(42 . 1) '(43 . 1) '(50 . 0) ) ) ) ) ) ) Edited March 31, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
tixtax Posted April 7, 2020 Author Share Posted April 7, 2020 It works like a charm! Thank you very very much Jonathan. Man, you made my day, this routine helps me doing my drawings hundred times faster! Actually this is a pressurized irrigation system project with Manifolds (blue polylines), Laterals (purple polylines), Risers (blue blocks) and Gate valves (orange blocks), also the red polyline is cadastre of a farm. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.