View Full Version : Point from entsel
wommack
2006-12-13, 11:28 PM
If (setq wall1 (entsel "\nPick a line: ")) returns: (<Entity name: 7efd1a58> (-25.5192 -16.7811 0.0))
Then (setq PT2 (cdr wall1)) returns: ((-25.5192 -16.7811 0.0))
I want PT2 to be this point, but it’s got an extra set of parentheses around it. How do I get rid of the outside parentheses?
If (setq wall1 (entsel "\nPick a line: ")) returns: (<Entity name: 7efd1a58> (-25.5192 -16.7811 0.0))
Then (setq PT2 (cdr wall1)) returns: ((-25.5192 -16.7811 0.0))
I want PT2 to be this point, but it’s got an extra set of parentheses around it. How do I get rid of the outside parentheses?
Give (setq PT2 (cadr wall1)) a shot.
wommack
2006-12-14, 03:47 PM
That gives me the same result. I can't find a way to remove the parentheses, which is not a value in the list, so car cdr and cadr don't have any effect.
That gives me the same result. I can't find a way to remove the parentheses, which is not a value in the list, so car cdr and cadr don't have any effect.
Which parenthesis are you trying to remove?
(setq wall1 (entsel "\nPick a line: "))
(setq PT2 (cadr wall1))
This would provide a list of two items for the variable wall1. This would also set the value of PT2 to a list of three items, the coordinates of the pick point. If you are trying to remove the parenthesis from the coordinates, you would have to use car, cadr, caddr for each of three portions of the coordinate.
What is your ulimate goal or value you are seeking? What do you plan on doing with the value?
wommack
2006-12-14, 05:27 PM
I want to remove the extra parentheses from the value stored in PT2, which is ((-25.5192 -16.7811 0.0)). I need it to read: (-25.5192 -16.7811 0.0)
I want to remove the extra parentheses from the value stored in PT2, which is ((-25.5192 -16.7811 0.0)). I need it to read: (-25.5192 -16.7811 0.0)
cadr seems to do what you are trying to do here (see attached). Or am I missing something?
I want to remove the extra parentheses from the value stored in PT2, which is ((-25.5192 -16.7811 0.0)). I need it to read: (-25.5192 -16.7811 0.0)
Where are you getting this value, ((-25.5192 -16.7811 0.0))? You would need to use CAR to get the first element of a list. The second one would be CADR, and the third would use CADDR. There are some other ones as well.
wommack
2006-12-14, 06:53 PM
cadr works. I must have done something wrong yesterday. I don't know what as I cut and pasted the values for !pt2 from the command prompt, and yesterdat it had the second set of parentheses in it. This stuff hurts my brain.
cadr works. I must have done something wrong yesterday. I don't know what as I cut and pasted the values for !pt2 from the command prompt, and yesterdat it had the second set of parentheses in it. This stuff hurts my brain.
I'm glad you worked it out. :)
It does get easier with experience; hang in there...
Adesu
2006-12-15, 12:09 AM
Hi wommack,
Do you mean like this
(setq wall1 (entsel "\nPick a line: ")) ; (<Entity name: 7ef60ea0> (18.171 20.8006 0.0))
(setq PT2 (cdr wall1)) ; ((18.171 20.8006 0.0))
(setq PT2 (car PT2)) ; (18.171 20.8006 0.0)
cadr works. I must have done something wrong yesterday. I don't know what as I cut and pasted the values for !pt2 from the command prompt, and yesterdat it had the second set of parentheses in it. This stuff hurts my brain.
Hi wommack,
Do you mean like this
(setq wall1 (entsel "\nPick a line: ")) ; (<Entity name: 7ef60ea0> (18.171 20.8006 0.0))
(setq PT2 (cdr wall1)) ; ((18.171 20.8006 0.0))
(setq PT2 (car PT2)) ; (18.171 20.8006 0.0)
Adesu,
Are you trying to clarify how wommack received the incorrect value? The extra steps you suggest are not needed with the cadr function.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.