Author Topic: Field Date in a attribute  (Read 2272 times)

0 Members and 1 Guest are viewing this topic.

fabcad

  • Newt
  • Posts: 43
Field Date in a attribute
« on: October 26, 2011, 04:18:43 AM »
Hello,

How to Populates a selected attribute with a Field referencing the date.

Syntax of the date field :

%<\AcVar Date \f "d MMMM yyyy">%

Thanks,

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Field Date in a attribute
« Reply #1 on: October 26, 2011, 05:23:07 AM »
If you want to add that through lisp, then you need to escape the special characters such as backslash and double quote with a preceding backslash. The easiest way I know to get this is to use the getstring method. Copy the following to your command-line:
Code: [Select]
(getstring t "Paste string: ")Then paste the text you want into that. It should return the string with the needed escapes:
Code: [Select]
Command: (getstring t "Paste string: ")
Paste string: %<\AcVar Date \f "d MMMM yyyy">%
"%<\\AcVar Date \\f \"d MMMM yyyy\">%"
Then you need to set the text/attrib/etc.'s text value to that string. Either using the dxf data list as obtained from entget and then subst a new (1 . "new string") for the old (assoc 1 dxflist), then use entmod to modify to match the new DXF list. Or using the vla-object of the text/attrib and setting its TextString property to the new string.

There's pro's and con's to both: The entmod screws up with annotative text - so try to remove stuff like height & width when using this. The vla method has trouble with UniCode characters.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

fabcad

  • Newt
  • Posts: 43
Re: Field Date in a attribute
« Reply #2 on: October 26, 2011, 07:57:40 AM »
Thanks irneb,

The syntax is correct, the field fills with the date but displays # # # # instead. But by updating the field by the AutoCAD command, the date is displayed.

What should I add to prevent the manual update of the field in question.

thank you,

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Field Date in a attribute
« Reply #3 on: October 26, 2011, 08:17:54 AM »
You could choose any of several ideas: e.g. issue the UdpateField command through the lisp function; issue a regen command; use the vla-RegenAll function on the current view; etc. Generally I simply do a regen when I've added field codes.

I think if you go with the vla method you need not go through this scenario, though I can't remember. You might need to check.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Field Date in a attribute
« Reply #4 on: October 26, 2011, 10:11:49 AM »
If you want to add that through lisp, then you need to escape the special characters such as backslash and double quote with a preceding backslash. The easiest way I know to get this is to use the getstring method.
I find it easiest to just create the field in a piece of text then use (vla-getfieldcode (vlax-ename->vla-object (car (entsel)))) to extract. Very little legwork.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox