Calling out a polyline lenght
I am doing some piping diagrams, and would like to call out the length of a polyline.
I just did some searching to try to find a lisp routine, when I found this article on using fields to display the area of a closed polyline.
I followed it, and was able to create a leader, with a field to show the length of the polyline. The field can show the length, but that length is not dynamically updated automatically. Note that the drawing must be regenerated for any changes to show up if you stretch the polyline. Currently, the steps are;
- Create a leader with Mtext.
- Choose to insert a field.
- Choose OBJECT/OBJECT.
- Select the polyline.
- Choose from a list of properties about that polyline.
Is there any way to have a field that automatically updates, without having to remember that you must regenerate the drawing?
Any suggestions about how to approach this as a Lisp program or macro? Any suggestions about existing routines that can help automate the multiple steps?
Thanks for any help.
-Joe
0
Comments
-
I found another discussion that has a lisp routine to place text with the length of selected lines. However, it is not associative in any way.[code];Creates a command GetLength that will insert text showing the;lenght of a selected polyline.;(vl-load-com)(defun C:GetLength (/ intCount entItem sngLength objItem)(setq ssSelections(ssget (list (cons 0 "*LINE,ARC")))sngLength 0)(repeat (setq intCount (sslength ssSelections))(setq intCount (1- intCount)entItem (ssname ssSelections intCount)objItem (vlax-ename->vla-object entItem)sngLength (+ sngLength(vlax-curve-getDistAtParamobjItem(vlax-curve-getEndParam objItem)))))sngLength(if (zerop (cdr (assoc 40 (entget (tblobjname "style" (getvar"textstyle"))))))(vl-cmdf ".text" (getpoint "\nPick point for text ") (getvar"textsize") 0.0 sngLength)(vl-cmdf ".text" (getpoint "\nPick point for text ") 0.0sngLength)))[/code]-Joe0
-
I came across another LISP routine that us supposed to call out the area of a polyline. And in this case it is supposed to put a field, that will automatically update whenever you regenerate the drawing. However, it is not working for me. The text in the leader shows,AREA = %%).AreaIs this not working because I am attempting to use it in BricsCAD, and some feature is not supported?-JoeHere is the discussion where I obtained the LISP, also listed below.[code](defun C:FA (/ acsp adoc cpt elist en ent fld lead_obj lpt mtx oid osm)(vl-load-com)(or adoc(setq adoc(vla-get-activedocument(vlax-get-acad-object))))(if (and(= (getvar "tilemode") 0)(= (getvar "cvport") 1))(setq acsp (vla-get-paperspace adoc))(setq acsp (vla-get-modelspace adoc)))(setq osm (getvar "osmode"))(setvar "osmode" 0)(while(setq ent (entsel "\nSelect pline or hit Enter to exit"))(setq en (car ent))(if (wcmatch (cdr (assoc 0 (setq elist (entget en)))) "*POLYLINE")(progn(setq cpt (trans (cadr ent)1 0)lpt (trans (getpoint cpt "\nPick the ending point of leader:") 1 0))(setq oID (vla-get-objectid (vlax-ename->vla-object en)))(setq fld(strcat(strcat "AREA = " "%<\\AcObjProp Object(%<\\_ObjId " </div>(itoa oID)">%).Area \\f \"%pr1%lu2%ct4%qf1 S.F.\">%""\\P")))(setq mtx (vlax-invokeacsp 'AddMText lpt 0.0 fld))(vlax-put mtx'AttachmentPoint(cond ((> (car cpt) (car lpt))6)((< (car cpt) (car lpt))4)(T 4)))(vlax-put mtx 'Height (getvar "textsize"))(setq lead_obj (vlax-invokeacsp'Addleader(apply 'append (list cpt lpt))mtxacLineWithArrow))(vlax-put lead_obj 'VerticalTextPosition 0);1)))(setvar "osmode" osm)(princ))(princ "\n Start command with FA ...")(princ)[/code]0
-
All my efforts to insert code using the "insert code" feature on the forum have failed. So, here I will try a few variations.The first version is totally unmodified[code]PASTE CODE HERE[/code]Then I replaced the "PASTE CODE HERE"[code]This is just one line as a test[/code]Now trying with a carriage return added[code]Line1 of the code then carriage returnAnother line of code[/code]-Joe0
-
Apparently you can only put a single line of code in the code window.-Joe0
-
It seems I am having a conversation with myself. Hopefully it will help some other people if they are searching for similar functionality.This message is about an important functionality limitation of fields in BricsCAD. When I had to re-draw one of the polylines, I discovered that if the associated polyline is deleted, and the drawing regenerated, the field does not show any change, but rather keeps its prior value. The end result looks as though the text is current, but it is not.Even if this is normal functionality, it should be modified to show that the field is no longer valid. When drawings show incorrect information, it is a serious problem in a CAD program. I have already submitted a support request to Bricsys, that they correct this in a future release.Another minor addition is to suggest that they change how a field is displayed. Often the color of a field does not allow it to be readable with the grey background. AutoCAD does not allow any sort of editing of the color, and so BricsCAD's functionality is the same as AutoCAD. But, perhaps some other method would be better, perhaps a dotted underline, or something like that would improve on what AutoCAD does.-Joe0
-
... the drawing regenerated, the field does not show any change, but rather keeps its prior value...
What is your FIELDEVAL setting?
Re: grey background. Have you tried turning it off via FIELDDISPLAY?0 -
Thank you for the reply. I don't feel so lonely on this thread anymore.FIELDEVAL was set to 31. So, it should update on a regen.But, I am not certain what to expect for normal behavior when the entity a field is associated with is erased. I would think the field should somehow reflect that fact. Currently, in my drawing, if I create a field inside Mtext that shows the Length of a polyline, and later delete the polyline, the field shows the length from before I deleted the polyline, even when I regenerate.What sort of behavior should I expect when the object a field based on an object is deleted?-JoeAlso, my FIELDDISPLAY setting is On. I know it will be readable onscreen if I have it off. But, then I won't know when text is a field or not. That is why I suggested something like the dotted underline as an alternative.0
-
... field inside Mtext that shows the Length of a polyline, and later delete the polyline, the field shows the length from before I deleted the polyline, even when I regenerate....
I suspect the field value is "confused" in that it attempts to show the value of an entity which does not exist.
Workaround: Rather than delete, set length of polyline to ZERO. Field will display 0.0000.0 -
Joe, why not just read the polyline's length and area in the Properties palette?0
-
The goal is to create associative text on a leader.-Joe0
This discussion has been closed.