Want input from user to search the DWG file for a block name:
(setq INSERTNAME (getstring "\n Select Block to Replace:"))
After getting the block name I want to stick the name into the definition function:
(setq XNAME '((2 . "Your_Block_Name_Here")) )
^ INSERTNAME ^
Then I want to search the dwg file for the definition function:
(setq BLOCKNUMBER (ssget "_x" XNAME))
How do I get INSERTNAME into XNAME that makes BLOCKNUMBER work?
This works if I manually put in the name of the block in the "Your_Block_Name_Here" space.
I know this a dirt simple answer I'm spacing on...
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Since the quote or apostrophe will mark an expression as literal, no symbols or expressions will be evaluated within the literal expression.
Hence, for the INSERTNAME symbol to be evaluated within the list, you would need to use a combination of the list & cons functions to construct the ssget filter list, e.g.:
(setq BLOCKNUMBER (ssget "_X" (list '(0 . "INSERT") (cons 2 INSERTNAME))))
Observe that the additional '(0 . "INSERT") list has been quoted since it does not contain expressions or symbols to be evaluated.
More information on the apostrophe may be found here.
1. Simple if all you needed to know was that a definition was a list.
2. Luck has nothing to do with anything, and never has. If you believe this then we should play poker some time.
3. The fact I had an answer that worked in less than an hour as compared to some questions I have asked that took days, must mean I got the best result.
4. If INSERTNAME variable used for the name the user insert isn’t clear enough, then I’m “lucky” I’ll never have to figure out your programs.
Have a good day...
I'm happy to help Snowman, and I'm glad that my solution was comprehensible; however, I would agree with stevor's point regarding a more descriptive thread title since this will ensure that the thread (and hence the solution) is easier to find through the forum's search utility for others tackling a similar problem - on this topic this article is a good read.