TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nobody on November 03, 2017, 02:44:25 PM
-
Is there a way to rename lisp variables / functions through entire files easily?
-
Its called Replace :2funny:
You could write a lisp that looks for "setq" in a line, then "setq variable" and change the variable name, only problem is code with (setq a 1 b 2) when using wcmatch it gives a starting point so step across the string till the next space after the variable. change the variable name and rewrite the line. It is doable needs a lambda function for the replace bit. Need to think about it a bit more.
In my case I want to add AH- to variable names to make them individual its a bit easier than changing the whole name. Oh yeah need to check the starting (defun statement also ( / pt1 pt2 ) etc
-
Use a good text editor. Any good editor should support regex.
-
I think it can be a bit tricky just doing a replace across multiple list files.
Some variables share letters that may be replaced.
Setq can have many variables (setq a 2 b5 c 8)
-
Like you Cab as you run it would ask old variable new variable name making a list which will grow its a bit of a task. Using a macro in word may be easier looking for a number of predefined variable names. I use stuff like pt pt1 all the time but the names could be a bit trickier. layname layername lname etc all the same depending on what I feel like when typing. It may need a 1st pass get all variable names make a list with pairs old new then second pass actually change them. Obviously making a new file.
-
Thanks guys, looks like I'll need to just grind through. Appreciate it!
-
Yeah no quick solution just me though I stay away from *acad* as variable names always get worried about using characters like *.
I know that commercially I would add a prefix to all my defuns.
Making c:now can be a risk if someone else uses now, so usually make my defun naming a bit obscure c:ahfindints
-
Look into "TextCrawler".
-
Look into "TextCrawler".
Thanks!
-
Any good editor should allow you to use regex.
Also, you could also use the preprocessor I built (it's called LiFP) to do simple search and replace.
https://www.theswamp.org/index.php?topic=37700.0
-
Any good editor should allow you to use regex.
Also, you could also use the preprocessor I built (it's called LiFP) to do simple search and replace.
https://www.theswamp.org/index.php?topic=37700.0
Thanks seven...impressive as always.