Does anybody know of a way to lebel a polyline or a feature line with its layer name without using mtext and fields/objects.
Basically i would like to be able to add a label, select the polyline/feature line and it will label it with the layer name at appropriate offset and also be orientated along the line.
Thanks for your help, Patrick
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
I think the option of a field would probably be the best idea because if you change the assigned layer, the field will update.
But to answer the question as asked, you could probably do what you're looking for with a lisp routine (and if you go that route, you could even include a reactor that will recognize the layer change and update the label accordingly). This would be a lot more complex than using a field though.
Don Ireland
Engineering Design Technician
@PatrickManson wrote:
Does anybody know of a way to lebel a polyline or a feature line with its layer name without using mtext and fields/objects.
Basically i would like to be able to add a label, select the polyline/feature line and it will label it with the layer name at appropriate offset and also be orientated along the line.
Thanks for your help, Patrick
What is you adversion to mtext fields for this task? If you cannot use them you will need to find a lisp routine. But as Doni states fields would be the way to go.
Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Thanks for the replies. the main reason for trying to find a better way to label the line without using the fields, is that it is a labourious process to do so. I need to copy the mtext, edit the field, then rotate the text appropriately.
Cheers
There is a board specifically for Autolisp questions. You could easily write a routine that will prompt the user for a pline, find out the angle at that location, and place the mtext object with the field in it (at the appropriate angle). Putting the field in the mtext object will be the most difficult portion of this task and I could figure out how, I just don't have time right now to get into that.
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/bd-p/130
Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Here's a very quickly written lisp to label an objects' layer. No error checking provided, so will fail on non-curve objects (a 'curve' object is a line, arc, polyline, spline, ray, etc.). But the meat of the needed items are here.
(defun c:labelobjlayer(/ LM:objectid model ent obj DIR INSPT MTEXT OFFSET PARM PT TEXT VEC) ;; ObjectID - Lee Mac lee-mac.com & theswamp.org ;; Returns a string containing the ObjectID of a supplied VLA-Object ;; Compatible with 32-bit & 64-bit systems (defun LM:objectid ( obj ) (eval (list 'defun 'LM:objectid '( obj ) (if (and (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*") (vlax-method-applicable-p (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))) 'getobjectidstring) ) (list 'vla-getobjectidstring (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))) 'obj ':vlax-false) '(itoa (vla-get-objectid obj)) ) ) ) (LM:objectid obj) ) (setq model (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (while (setq ent (entsel "\nSelect object to label with layer name: ")) (setq obj (vlax-ename->vla-object (car ent)) pt (vlax-curve-getclosestpointto obj (cadr ent)) parm (vlax-curve-getparamatpoint obj pt) vec (vlax-curve-getfirstderiv obj parm) dir (angle '(0 0 0) vec) offset 2.0 ;;adjust to desired offset may want to scale this based on annoscale inspt (polar pt (+ dir (* pi 0.5)) offset) ) (setq text (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid obj) ">%).Layer>%")) (setq mtext (vlax-invoke model 'addmtext inspt 0 text)) (vla-put-rotation mtext dir) (vla-put-attachmentpoint mtext acbottomcenter) ) (princ) )
Thanks Jeff, have loaded it - excuse my ignorance, but what command do i use to start the lisp?
Cheers
Is it possible to use this command for all the objects in my drawing? I mean select all lines and label them automatically...
I bet your customers would like this and would like to see it work through an xref as well when the time is right. 🙂
John Mayo
This is a 20 year old lisp that I still use sometimes. No error checking or much of anything else. It also inserts the text parallel to the current view.
Allen
(defun c:laylab () (setq ENT (car (entsel))) (setq ENL (entget ENT)) (setq LN (cdr (assoc 8 ENL))) (setq IPT (getpoint "\nInsertion Point?")) (setq CL (getvar "clayer")) (setq VT (getvar "viewtwist")) (setvar "clayer" LN) (command "text" IPT "" pause LN) (setvar "clayer" CL) )
Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
is there any way to add the selected text or mtext to the selected feature line(s). similar to attaching table or attributes to line in acadmap.
Can't find what you're looking for? Ask the community or share your knowledge.