ESRI_BONUS_FOREACHFEATURE to edit text

231
2
04-11-2018 09:20 AM
SteveJavins
New Contributor II

Could the ESRI_BONUS_FOREACHFEATURE tool be used to update pieces of text if they belong to a local feature class? I'm wondering if it's possible to add a prefix 'for each' text entity I select. I have no experience writing in AutoLISP, but it seems like the tool could potentially run a function that would add the prefix. edit text.# #LISP

Tags (2)
0 Kudos
2 Replies
DonKuehne
Esri Contributor

Steve,

Certainly. That would be an excellent use. You would supply an autolisp statement or AutoLISP function that would use the Entity value supplied by the function to grab the text value and modify it with some form of entity modification… You’re function or statement would likely include the (entmod) autolisp routine where you grabbed the current value and did your text concatenation. From the included help document you will see:

  • An AutoLISP global variable called ESRI_CALC_ENT is populated with the entity name of the current feature being processed. Your AutoLISP expression can take advantage of this fact to perform complex actions with knowledge of the current entity, such as modifying its geometry or accessing its graphic properties.

-Don

0 Kudos
SteveJavins
New Contributor II

Thank you Don.

I still have a lot of questions . I'll try to limit since this may not be the best place for them.

1.

If I were to implement using 'FOREACHFEATURE', would I define the new function inside of the afa_utilities.lsp file and then call that function inside the expression when running the tool?

2.

I'm able to use the Field Calculate tool using this expression, (strcat “#” [FIELD_NAME]). I only want to let users quickly add this prefix to the same extracted feature class labels each time. I tried to create and load a separate tool like this:

(defun c:addhash ()
  (prog (load "afa_utilities") (c:ESRI_CALCULATEFIELD))
  (command "ESRI_CALCULATEFIELD" "FIELDNAME" "(strcat “#” [FIELDNAME])")
  (princ)
)

However the tool ignores the field name and expression I supply. Do you have any suggestions?

Thanks, Steve.

 

0 Kudos