lisp layer and lenght or text in tool

lisp layer and lenght or text in tool

Anonymous
Not applicable
641 Views
3 Replies
Message 1 of 4

lisp layer and lenght or text in tool

Anonymous
Not applicable
Hello

I look for a lisp that would do this :

- Choice of a polyline
- Writing a text in the middle of each segment, Arial size 0.6 , above the polyline indicating the layer name and the segment length

I can not find my happiness ...

Otherwise, since the _text control my toolbox , I thought to add to the command ^ C ^ C_text a line to insert a field " Layer" and "length" field. But I can not do it either ...

I'm french, soory if lisp exist and I don't find ! 

Thank you
0 Likes
642 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

Hi,

just an idea... explode polylines (perhaps just a copy in another drawing )... and then use this Lee Mac's routine. 

...then adding the layer name is simple enough.

 

0 Likes
Message 3 of 4

ВeekeeCZ
Consultant
Consultant

This code may be better...

 

Spoiler
(defun c:SegLen ( / ss i en par len pt txt)
  
  (if (and (princ "\nNeed geometrical entities, ")
	   (setq ss (ssget '((0 . "ARC,LWPOLYLINE,LINE"))))
	   (or (tblsearch "STYLE" "Arial_0.6") 				; TEXT STYLE NAME
	       (entmake (list (cons 0 "STYLE")
			      (cons 100 "AcDbSymbolTableRecord")
			      (cons 100 "AcDbTextStyleTableRecord")
			      (cons 2 "Arial_0.6")			; TEXT STYLE NAME (same as above)
			      (cons 70 0)
			      (cons 40 0.6)
			      (cons 3 "Arial.ttf"))))
	   )
    (repeat (setq i (sslength ss))
      (setq en (ssname ss (setq i (1- i)))
	    par (vlax-curve-getEndParam en))
      (repeat (fix par)
	(if (and (setq len (- (vlax-curve-getDistAtParam en par)
			      (vlax-curve-getDistAtParam en (setq par (1- par)))))
		 (setq pt  (vlax-curve-getPointAtParam en (+ par 0.5)))
		 (setq txt (strcat (cdr (assoc 8 (entget en)))
				   "\\P"
				   (rtos len 2)))
		 )
	  (entmake (list (cons   0 "MTEXT")
			 (cons 100 "AcDbEntity")
			 (cons 100 "AcDbMText")
			 ;(cons   8 "TEXT")				; ERASE THE FIRST ";" CHANGE TEXT'S LAYER NAME
			 (cons  10 pt)
			 (cons   1 txt)
			 (cons  71 8)))))))
  (princ)
)

See the red notes... you can change TEXT STYLE name or LAYER name for new texts.

 

Hope this will help you find your happiness.

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
....
I look for a lisp that would do this :

- Choice of a polyline
- Writing a text in the middle of each segment, Arial size 0.6 , above the polyline indicating the layer name and the segment length
....

Clarify something for me:  I'm curious as to why the Layer name should be in all the segment labels on a given Polyline, since that Layer name will be the same in all of them.  

 

You may be interested in DimPoly.lsp, with its DPI and DPO commands, available here.  It has two commands, giving you the choice whether to put the Text inside or outside the Polyline segments.  It uses Aligned Dimensions on line segments, which means that if you make a Dimension Style that suppresses both extension lines and both dimension lines, the results will look just like Text/Mtext, but unlike such labeling routines that make Text/Mtext objects, on line segments they will update automatically if you Stretch the shape of the Polyline differently.  [See comments in the file about those on arc segments, which it labels with Angular Dimensions with text override for the length].

 

If you really do want the Layer name included along every segment, that can be added to DPI and DPO easily enough.

Kent Cooper, AIA
0 Likes