View Full Version : Need help with a way to access information inside of my lisp...
timothyjturner
2006-03-01, 09:55 PM
So I'm making a program and I'm trying to come up with the easiest way to store variable data on different blocks that im inserting....So my program can use the data to prompt the user to make simple changes to the blocks.
My idea was to use dotted pairs. Here is an example of what I tried to do....
(setq objectAlist (cons 'length 10) (cons 'instructions 5) (cons 'insertA objectAA) (cons 'insertB objectAB) (cons 'insertC objectAC))
;; I'm doing this so that the program gets the objects length, instructions, and filename
;; for the block. There are many of these dotted pair lists. (one for each block) about 100.
(setq objectid (getstring "\n ENTER OBJECT IDENTIFICATION OR 'N' FOR NEW LINE:"))
(command "insert" (strcat "C:\\Program Files\\acadlisp\\objects\\" (cdr (assoc 'insertA (strcat (objectid "list"))) coordinates "1" "1" "0")
This does not work like i wish it would. I know that the problem is that when I try to access the dotted pair, it would like the variable name and not that string that I have provided that matches the variable name. Can somebody come up with a quick and easy way around this? It would be very very well appreciated. Thanks!
[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]
So I'm making a program and I'm trying to come up with the easiest way to store variable data on different blocks that im inserting....So my program can use the data to prompt the user to make simple changes to the blocks.
My idea was to use dotted pairs. Here is an example of what I tried to do....
(setq objectAlist (cons 'length 10) (cons 'instructions 5) (cons 'insertA objectAA) (cons 'insertB objectAB) (cons 'insertC objectAC))
;; I'm doing this so that the program gets the objects length, instructions, and filename
;; for the block. There are many of these dotted pair lists. (one for each block) about 100.
(setq objectid (getstring "\n ENTER OBJECT IDENTIFICATION OR 'N' FOR NEW LINE:"))
(command "insert" (strcat "C:\\Program Files\\acadlisp\\objects\\" (cdr (assoc 'insertA (strcat (objectid "list"))) coordinates "1" "1" "0")
This does not work like i wish it would. I know that the problem is that when I try to access the dotted pair, it would like the variable name and not that string that I have provided that matches the variable name. Can somebody come up with a quick and easy way around this? It would be very very well appreciated. Thanks!
This bit of code seems to be your problem.
(command "insert"
(strcat "C:\\Program Files\\acadlisp\\objects\\"
(cdr
(assoc 'insertA (strcat (objectid "list")))
coordinates "1" "1" "0")
You will need to look at what all of the prompts are for the command line version of the insert command.
The concatenation of your block name is not correct. You will need to look for the 'insertA dotted pair from your variable that it is contained in objectAlist
(strcat "C:\\Program Files\\acadlisp\\objects\\"
(cdr (assoc 'INSERTA objectAlist))
)
I am not quite sure what you are doing with the remainder of your code. What is the purpose for (objectid "list")?
timothyjturner
2006-03-01, 10:43 PM
I wrote that code up a little too fast... The (objectid "list")? should not have parenthesis around it, it should probably look like this... There is no such function called objectid, just the string i wanted to strcat with "list"...
That line should probably look like this...
(command "insert" (strcat "C:\\Program Files\\acadlisp\\objects\\" (cdr (assoc 'insertA (strcat objectid "list")))) coordinates "1" "1" "0")
I'm trying to access objectAlist (or a different list) somehow by only using the string input from prompting the user. This is my dillema.
timothyjturner
2006-03-01, 10:51 PM
I suppose if someone could just write me a small sample lisp routine that will save some sort of data inside the lisp that can be saved to a variable in a program when the user of the program enters a string to query it... I guess taht's all im having trouble with. Or you could modify my code to do what I'm trying... Either or and that would be great.
Thanks!
I wrote that code up a little too fast... The (objectid "list")? should not have parenthesis around it, it should probably look like this... There is no such function called objectid, just the string i wanted to strcat with "list"...
That line should probably look like this...
(command "insert" (strcat "C:\\Program Files\\acadlisp\\objects\\" (cdr (assoc 'insertA (strcat objectid "list")))) coordinates "1" "1" "0")
I'm trying to access objectAlist (or a different list) somehow by only using the string input from prompting the user. This is my dillema.
When you are trying to create a dynamic name for a variable to be placed within the assoc, you will first need to READ the string and then EVAL what was read.
(command "_.insert"
(strcat "C:\\Program Files\\acadlisp\\objects\\"
(cdr (assoc 'INSERTA
(eval (read (strcat "object" OBJECTID "list")))
)
)
)
COORDINATES
"1"
"1"
"0"
)
peter
2006-03-02, 01:15 PM
[code]
(setq objectAlist (list (cons 'length 10) (cons 'instructions 5) (cons 'insertA objectAA) (cons 'insertB objectAB) (cons 'insertC objectAC)))
This will help the list.
I would also use ldata to attach the list after the block has been inserted
(vl-ldata-put (vlax--ename->vla-object (entlast)) "ALIST" objAlist)
use some way to get the block obj as objItem
To get the info back use (vla-ldata-get objItem "ALIST")
Peter Jamtgaard
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.