Jump to content

Recommended Posts

Posted

Hi All, i'm trying to make a new linetype with text, but i want the text to have a field that displays the length of the line. Does anyone know how to do this? Or if it's possible?

Any help would be much appreciated!

Posted

thanks ReMark, the reason I would want it to be a linetype though would be so that I can have multiple segments, like as a polyline, and it can display the total length of the polyline. I'm thinking something like the GAS linetype or the HOT WATER supply linetype, but where the text is a field.

Posted

Can't say I've seen anything like that and any workaround I have tried has been too clunky.

Posted

On a single line it can be done using a dimension, but thats not applicable for a pline.

 

Like Remark what about just pick and update objects or search by layer etc.

Posted

Someone might know a way with LISP, you could use the measure command and insert a block with a field along a line/pline, you could of course add other text or a wipeout or background hatch

field.dwg

Posted (edited)

This is based on Steven-g dwg it will label but if you change the pline the blocks do not change, one way around this is to erase all the blocks move the pline then redo the (c:plen), this involves other routines but the method is quite simple using ssget "F" done below

 

Simplest is the need to be able to put the field in a .LIN

A,5.08,-5.08,5.08,-5.08,["G",STANDARD,S=1.8,R=0.0,X=-1.8,Y=-.9],-3 need the "G" to be a field.

 

(defun c:plen ( / obj)
(setq obj (entsel "Pick line or pline"))
; probably want a layer set here
(command "measure" obj "B" "len" "Y" (getdist "enter spacing"))
)

 

; pline co-ords example
; By Alan H
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq len (length co-ords))
(setq numb (/ len 2)) ; even and odd check required
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)

; erase blocks 
(defun c:eraseblk ( / ss)
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(co-ords2xy) ; list of 2d points making pline
(setq ss (ssget "f" co-ordsxy (list (cons 0 "Insert"))))
(command "erase" ss "")
)

Edited by BIGAL
Posted

Thanks everyone,

BIGAL, I used the first code you wrote above and saved it as a .lsp, loaded it with appload, and used the command "plen" on steven-g's drawing. It placed a measurement along my pline in regular intervals, which is great! but the measurement was always 15.81 m... which was the length of steven-g's line that he drew. When I draw a new line, it doesn't know to measure that one. Maybe the answer is in the second code you provided... but my novice autocad brain doesn't understand what to do with it.

Posted

I tested the small plen again at 2000 as spacing on a new pline and works fine, you may need to play with the dynamic block in terms of scale etc for small distance.

 

Used Bedit to edit block maintain insertion point.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...