Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A Very Simple (I can't believe I'm asking this) LISP Input Question...

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Snowman427
454 Views, 4 Replies

A Very Simple (I can't believe I'm asking this) LISP Input Question...

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...

 

 

 

 

4 REPLIES 4
Message 2 of 5
Lee_Mac
in reply to: Snowman427

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.

Message 3 of 5
stevor
in reply to: Snowman427

1. It is not very simple, when it is large enough to actually do something useful. 2. Your are lucky Lee looked into you mislabeled posting. 3. To get the best results, use a subject that refers to the actual problem. 4, Same for the names used fo variables, helps reduce confusion in the head of the reader, and writer.
S
Message 4 of 5
Snowman427
in reply to: stevor

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...

Message 5 of 5
Lee_Mac
in reply to: Snowman427

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost