View Full Version : Fields
delliott
3rd Mar 2008, 10:56 pm
Can an attributed text be turned in to a field without having to redo the text and make it mtext?
dbroada
4th Mar 2008, 11:11 am
I'm a little confused. To me an attribute is a part of a block. If you want a field in a block it can be defined at the ATTDEF stage by using Right Click|INSERT FIELD as the default or by using Right Click|INSERT FIELD when modifying a block.
I have just checked and Fields can be inserted into either DTEXT or MTEXT.
ASMI
4th Mar 2008, 11:26 am
Any text object can be transformed to field. Open field editor, make field, copy field expression from bootom box and close field editor. For example plot time field:
%<\AcVar PlotDate \f "HH:mm:ss">%
Copy it expression to attribute value.
Attribute editor is only productivity tool, but you can make your own fields without it. Also some fields which not accessible with Field Editor.
ASMI
4th Mar 2008, 12:59 pm
For example get Model object Id:
Command:(vl-load-com)
Command: (vla-get-ObjectId(vla-get-ModelSpace(vla-getActiveDocument(vlax-get-acad-object))))
2130451704
And make field with Model total entities number:
%<\AcObjProp Object(%<\_ObjId 2130451704>%).Count>%
ASMI
4th Mar 2008, 02:07 pm
Just for fun. Small program for creation of field with total lengh of set of lwpolylines. Select polylines and pick to any text or mtext:
(defun c:sumfil(/ plSet strLst tObj)
(vl-load-com)
(princ "<<< Select polylines >>> ")
(if(setq plSet(ssget '((0 . "LWPOLYLINE"))))
(progn
(setq strLst(strcat "%<\\AcExpr (0 "
(apply 'strcat
(mapcar '(lambda(x)(strcat
" + (%<\\AcObjProp Object(%<\\_ObjId "
(itoa(vla-get-ObjectID x))
" >%).Length>%)"))
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr(ssnamex plSet))))))
")>%"))
(if(setq tObj(entsel "\nPick Text or MText > "))
(if
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-TextString
(list
(vlax-ename->vla-object
(car tObj))strLst)))
(princ "\nPlease select Text or MText at unlocked layer!")
); end if
(princ "\nPlease select Text or MText!")
); end if
); end progn
); end if
(princ)
); end of c:sumfil
**** EDIT ****
Field for sum length of 3 polylines:
%<\AcExpr (0 + (%<\AcObjProp Object(%<\_ObjId 2105059776 >%).Length>%) + (%<\AcObjProp Object(%<\_ObjId 2105059768 >%).Length>%) + (%<\AcObjProp Object(%<\_ObjId 2105059760 >%).Length>%))>%
Product of this program.
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.