I'm trying to combine two user inputs and a constant with setq without spaces so I can use it in an AutoCAD command.
I haven't seen a string command that does this. It always has spaces in between the fetched valvues.
Thanks for any help
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@Anonymous wrote:I'm trying to combine two user inputs and a constant with setq without spaces so I can use it in an AutoCAD command.
I haven't seen a string command that does this. It always has spaces in between the fetched valvues.
Thanks for any help
I wonder how you're doing it. For me, it doesn't do that if I don't include spaces in what I enter for the User inputs [a2 is the 'constant' in this case]:
Command: (setq a1 (getstring))
What <--- typed in
"What"
Command: (setq a2 "The" a3 (getstring))
Heck <--- typed in
"Heck"
Command: (strcat a1 a2 a3)
"WhatTheHeck"
Am I misunderstanding the problem? Am I at least correct that you want to put strings together without spaces in the first place, rather than remove spaces from the result after the fact, as others' suggestions are designed to do?
Hi,
Not sure, but somthing like: (vl-remove-if (function (lambda(x)(= x 32)) (vl-string->list MyString)) will remove the spaces from a string, and (vl-list->string listOfChar) will concatenate back the list.
You can put that on a function:
(defun StripOutBlanks(MyString)
(vl-list->string (vl-remove-if
(function
(lambda(x)(= x 32)))
(vl-string->list MyString)
)
)
)
use: (StripOutBlanks "Hi There")
return: "HiThere"
Gaston Nunez
This worked well. Thanks!
But the insert command wont accept "0,0" as an input. I've also tried:
(setq d1 '(0 0)) and set d1 in the command line for coordinate input but AutoCAD wont accept either.
ideas?
This is the code line:
(setq e (strcat a b aa))
(command "insert" e "" "0,0" "" "" "" "")
)
This is the reply I get:
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Point or option keyword required.
; error: Function cancelled
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
@Anonymous wrote:This is the code line:
(setq e (strcat a b aa))
(command "insert" e "" "0,0" "" "" "" "")
)....
As hmsilva suggested, you don't want that Enter [""] between the Block name and the insertion point. [It's not like object selection in an editing command, where you need to tell it you're done selecting -- you can't Insert more than one Block name at a time.]
Also, I think you have more Enters at the end than you need, unless maybe the Block includes an Attribute that you want to accept a default value for, and you have ATTDIA set to 0. And unless you need to have it saved for some later use, the Block name could just be "built" right inside the Insert command, with no need for the 'e' variable:
(command "insert" (strcat a b aa) "0,0" "" "" "")