TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on February 07, 2006, 02:55:12 PM
-
Sorry, I have to ask. Can someone show me how to manipulate dotted pair list.
("MyRoomInformation" (1000 . "ROOM NAME") (1000 . "Living Room") (1000 . "ROOM
NUMBER") (1000 . "123") (1000 . "AREA") (1040 . 55.2294))
I want the following:
Room Name "Living Room"
Room Number "123"
Area 55.2294
Gary
-
One way.
(setq MyList '("MyRoomInformation" (1000 . "ROOM NAME") (1000 . "Living Room") (1000 . "ROOM NUMBER") (1000 . "123") (1000 . "AREA") (1040 . 55.2294)))
(foreach Item (cdr MyList)
(setq tmp (vl-princ-to-string (cdr Item)))
(if tmpStr
(progn
(prompt (strcat "\n " tmpStr " " tmp))
(setq tmpStr nil)
)
(setq tmpStr tmp)
)
)
-
Thanks Tim
I find it hard to do the simplest things.
using your code I get:
123 ROOM NAME
Living Room ROOM NUMBER
123 AREA"55.2294"
So how would you do the list like in my previous example?
ROOM NAME Living Room
ROOM NUMBER "123"
area "55.2294"
Gary
-
Another way.... (I did add ":" after each description)
(while (setq lst (cdr lst))
(princ (strcat "\n" (cdar lst) ": "
(cond ((= (type (setq x (cdadr lst))) 'INT)
(itoa x))
((= (type x) 'REAL)
(rtos x))
((= (type x) 'STR)
(strcat "\"" x "\""))
)
))
(setq lst (cdr lst))
)
Edited to relocate the line feed
-
Thanks Jeff
ROOM NAME: "Living Room"
ROOM NUMBER: "123"
AREA: 4'-7 59/256"
That is what I wanted.
Now I just need to save these examples and not lose them.
Gary
-
Here is another one
(defun readxd (lst)
(if (cadr (cdr lst))
(cons (list (cdar (cdr lst))
(vl-princ-to-string (cdadr (cdr lst))))
(readxd (cddr lst)))))
-
Fatty
Thanks
(defun C:XDL1 (/ BMENT BMSEL ELST FOROBJ)
(vl-load-com)
(setq BMSEL (entsel "\n* Select Object to Get It's Xdata *"))
(if BMSEL
(progn
(setq BMENT (car BMSEL))
(vlax-for FOROBJ (vla-get-registeredapplications
(vla-get-database
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq ELST (entget BMENT (list (vla-get-name FOROBJ))))
(if (assoc -3 ELST)
(print (cadr (assoc -3 ELST))) (print (cadar (assoc -3 ELST)))
)
)
)
)
(prin1)
)
I get the following using Tim Willeys (c:RoomInfo):
(("ROOM NAME" "Living Room") ("ROOM NUMBER" "123") ("AREA" "55.2294"))
When I use:
(readxd '("MyRoomInformation"
(1000 . "ROOM NAME")
(1000 . "Living Room")
(1000 . "ROOM NUMBER")
(1000 . "123")
(1000 . "AREA")
(1040 . 55.2294)))
-
You can add more stuff to that routine Gary. Just have it prompt for my questions if that isn't enough for you. That is one I will be working on when I have time. Glad someone found a use for it.
-
Now I just need to save these examples and not lose them.
They are! :-)
-
Tim, Mark has a team of people who, every night, save threads that Mark has pre-nominated.
You have no worries, 'cause this is one of those threads ..
:lmao: