woodman78 Posted July 7, 2011 Posted July 7, 2011 Does anyone have a lisp to number the vertices on a pline?? So the user wold select the pline and numbers would be placed at all vertices. Quote
Lee Mac Posted July 7, 2011 Posted July 7, 2011 This could very easily be achieved using the vlax-curve-* functions, since the vertices of a Polyline have zero-based integer parameters. So the pseudo-code would look something like: Prompt for selection of Polyline Initialise a counter variable While the counter is less than the parameter of the end vertex (vlax-curve-getendparam) Add Text entity at the point described by vlax-curve-getpointatparam with content equal to 1+ the counter variable. Increment Counter Variable Quote
woodman78 Posted July 11, 2011 Author Posted July 11, 2011 Didn't even get to look at it yet LeeMac. Run off my feet between home and work at the moment. Hope to get a chance to have a look during the week. Quote
alanjt Posted July 11, 2011 Posted July 11, 2011 You could also set a counter at 0, then step through the entity data dump (entget) and use each 10 code. However, I'd go with the vlax-curve-getPointAtParam method (Lee described), as it's a lot less legwork. Quote
Tharwat Posted July 12, 2011 Posted July 12, 2011 My approach . (defun c:test (/ e ent n i j p) ;; Tharwat 12. 07. 2011 (if (and (setq e (car (entsel "\n Select a Polyline :"))) (member (cdr (assoc 0 (setq ent (entget e)))) '("POLYLINE" "LWPOLYLINE") ) (setq n 0 j 1 ) ) (while (> (setq i (1+ (fix (- (vlax-curve-getendparam e) (vlax-curve-getstartparam e) ) ) ) ) n ) (setq p (vlax-curve-getpointatparam e n)) (entmake (list '(0 . "TEXT") '(100 . "AdCbText") '(100 . "AdCbEntity") (cons 10 (trans p 1 0)) (cons 40 (getvar 'textsize)) (cons 1 (rtos j 2 0)) '(210 0.0 0.0 1.0) '(50 . 0.0) ) ) (setq n (1+ n) j (1+ j) ) ) (princ) ) (princ) ) Tharwat Quote
VVA Posted July 12, 2011 Posted July 12, 2011 COORN-export of coordinates with numbering. Numbers of points are drawn by the text on the current layer, the current style, current height (TEXTSIZE) Quote
Guest kruuger Posted July 12, 2011 Posted July 12, 2011 ... (cons 10 p) ... like this should be better maybe also: (setq XA (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 (trans '(0. 0. 1.) 1 0 T) T))) (cons 50 XA) k. Quote
Lee Mac Posted July 12, 2011 Posted July 12, 2011 (edited) Well, since there is already a lot of code being offered, here was how I would approach it: (defun c:test ( / e i j m n p s ) (if (setq s (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) n (cdr (assoc 210 (entget e))) m (vlax-curve-getendparam e) j -1 ) (while (<= (setq j (1+ j)) m) (setq p (trans (vlax-curve-getpointatparam e j) 0 e)) (entmakex (list (cons 0 "TEXT") (cons 7 (getvar 'TEXTSTYLE)) (cons 40 (getvar 'TEXTSIZE)) (cons 10 p) (cons 11 p) (cons 72 1) (cons 73 2) (cons 1 (itoa (1+ j))) (cons 210 n) ) ) ) ) ) (princ) ) Short and simple is usually the easiest to write and follow. Edited July 6, 2019 by Lee Mac Quote
Lee Mac Posted July 12, 2011 Posted July 12, 2011 (setq p (vlax-curve-getpointatparam e n)) (entmake (list '(0 . "TEXT") '(100 . "AdCbText") '(100 . "AdCbEntity") [color=red] (cons 10 (trans p 1 0))[/color] (cons 40 (getvar 'textsize)) (cons 1 (rtos j 2 0)) '(210 0.0 0.0 1.0) '(50 . 0.0) Tharwat, note that the vlax-curve* functions will returns points in WCS, not UCS :wink: Quote
Tharwat Posted July 12, 2011 Posted July 12, 2011 Tharwat, note that the vlax-curve* functions will returns points in WCS, not UCS :wink: Certainly . You're right Thank you . Quote
woodman78 Posted July 13, 2011 Author Posted July 13, 2011 Thanks for all the help. I gave it to the surveyors and they were well impressed but had a couple of requests. They were wondering if a Point could be included at each vertex, if a start number could be entered rather than starting at 1 every time and if the text could be offsetted to the RHS by 0.5. Also how do I alter the text height? Quote
alanjt Posted July 13, 2011 Posted July 13, 2011 Thanks for all the help. I gave it to the surveyors and they were well impressed but had a couple of requests. They were wondering if a Point could be included at each vertex, if a start number could be entered rather than starting at 1 every time and if the text could be offsetted to the RHS by 0.5. Also how do I alter the text height? I just noticed you have Civil 3D. Why not just create points and use the point number/description to label the polyline vertices? Would make things a lot easier and could be quickly dumped to send to a data collector. This method is really good for creating state-out work for crews. Quote
woodman78 Posted July 13, 2011 Author Posted July 13, 2011 Thanks for that alanjt. I'll check it out tomorrow. Quote
alanjt Posted July 13, 2011 Posted July 13, 2011 Thanks for that alanjt. I'll check it out tomorrow. No problem. C3D is incredibly powerful. Do yourself a favor and explore some of the menus. Quote
woodman78 Posted July 14, 2011 Author Posted July 14, 2011 Will do but our surveyors don't have civil 3D. They have map. I'll look into anyway. thanks. Quote
CADWORKER Posted July 6, 2019 Posted July 6, 2019 On 7/12/2011 at 3:19 PM, Lee Mac said: Well, since there is already a lot of code being offered, here was how I would approach it: ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] e i j m n p s ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] '((0 . [color=MAROON]"LWPOLYLINE"[/color])))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))) n ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 210 ([color=BLUE]entget[/color] e))) m ([color=BLUE]vlax-curve-getendparam[/color] e) j -1 ) ([color=BLUE]while[/color] ([color=BLUE]<=[/color] ([color=BLUE]setq[/color] j ([color=BLUE]1+[/color] j)) m) ([color=BLUE]setq[/color] p ([color=BLUE]trans[/color] ([color=BLUE]vlax-curve-getpointatparam[/color] e j) 0 e)) ([color=BLUE]entmakex[/color] ([color=BLUE]list[/color] ([color=BLUE]cons[/color] 0 [color=MAROON]"TEXT"[/color]) ([color=BLUE]cons[/color] 7 ([color=BLUE]getvar[/color] 'TEXTSTYLE)) ([color=BLUE]cons[/color] 40 ([color=BLUE]getvar[/color] 'TEXTSIZE)) ([color=BLUE]cons[/color] 10 p) ([color=BLUE]cons[/color] 11 p) ([color=BLUE]cons[/color] 72 1) ([color=BLUE]cons[/color] 73 2) ([color=BLUE]cons[/color] 1 ([color=BLUE]itoa[/color] ([color=BLUE]1+[/color] j))) ([color=BLUE]cons[/color] 210 n) ) ) ) ) ) ([color=BLUE]princ[/color]) ) Short and simple is usually the easiest to write and follow. How to use this. Should it be copied into text and renamed as lisp? Reply is appreciated. Quote
marko_ribar Posted July 6, 2019 Posted July 6, 2019 2 hours ago, CADWORKER said: How to use this. Should it be copied into text and renamed as lisp? Reply is appreciated. (defun c:test ( / e i j m n p s ) (if (setq s (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) n (cdr (assoc 210 (entget e))) m (vlax-curve-getendparam e) j -1 ) (while (<= (setq j (1+ j)) m) (setq p (trans (vlax-curve-getpointatparam e j) 0 e)) (entmakex (list (cons 0 "TEXT") (cons 7 (getvar 'TEXTSTYLE)) (cons 40 (getvar 'TEXTSIZE)) (cons 10 p) (cons 11 p) (cons 72 1) (cons 73 2) (cons 1 (itoa (1+ j))) (cons 210 n) ) ) ) ) ) (princ) ) 1 Quote
Lee Mac Posted July 6, 2019 Posted July 6, 2019 (edited) I've amended my earlier post to remove the colour tags - I daren't think how many thousand other such posts still exist with embedded formatting... Edited July 6, 2019 by Lee Mac 1 Quote
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.