View Full Version : Using commands in a cond statement
eleonard
2007-02-26, 06:42 PM
I have been thinking and trying to find my answer and have been completely unsucessful.
I have created a bunch of custom commands which insert certian blocks into a drawing. These are defined in my ddplat.lsp file which is where all of my code is for this routine. When I get to the part where based on user imput the correct blocks should be inserted I get a message that it is a unknown command. But if I type it on the command line it works just fine. what could I be doing wrong?
Here is just a portion of my routine.
This is typical of all the blocks I insert
(DEFUN C:BCCOUN()
(COMMAND "INSERT" "F:\\CAD_STANDARDS\\JUB\\boise-citycouncil" "3.7,9" "" "" "")
(PRINC))
This is what I have for a conditional statement. I don't want to use the insert command and type everything out that is defined above because I will be doing the same ones on a lot of my conditional statements. Does this make sence?
(cond
((= city1)(command "layout" "n" "sig2"
"layout" "s" "sig2");BOISE CITY
(command "CDHEALTH"
"ACHDACC"
"ADASUR"
"ADATREA"
"BCENG" "BCCOUN"
))
Thanks for your help.
EmilyL
Hi Emily,
When you define a command in lisp with (defun c:whatever), that command may be called from the command line as you describe. However, to use it within another lisp you must call it like so:
(c:whatever)
So if this:
(command "CDHEALTH"
"ACHDACC"
"ADASUR"
"ADATREA"
"BCENG" "BCCOUN"
)
is calling a number of lisp routines, just replace that with:
(c:CDHEALTH)
(c:ACHDACC)
(c:ADASUR)
(c:ADATREA)
(c:BCENG)
(c:BCCOUN)
HTH,
Jeff
Hi Emily,
What are you testing in the first condition? Is it supposed to be (= city 1) or (= city1 something). As it is, you don't have enough arguments for the = function and it will always return T, thus executing the first condition stuff all of the time.
Have a look in THIS THREAD (http://forums.augi.com/showthread.php?t=42122). There is a great explanation of cond and how it works (it's about the tenth post, by CAB2K).
Edit: And what miff said, also.
eleonard
2007-02-26, 07:30 PM
Hi Emily,
When you define a command in lisp with (defun c:whatever), that command may be called from the command line as you describe. However, to use it within another lisp you must call it like so:
(c:whatever)
So if this:
(command "CDHEALTH"
"ACHDACC"
"ADASUR"
"ADATREA"
"BCENG" "BCCOUN"
)
is calling a number of lisp routines, just replace that with:
(c:CDHEALTH)
(c:ACHDACC)
(c:ADASUR)
(c:ADATREA)
(c:BCENG)
(c:BCCOUN)
HTH,
Jeff
THANK YOU, THANK YOU!! That did it.
Emily
eleonard
2007-02-26, 07:42 PM
Okay another question. Now that I have the commands being used. I am now writing my next condition which will use a different set of commands. I am using a dialog box which has a list of applicable cities. This list I hope I have set up correctly.
setq citylist(list "Boise" "Caldwell" "Eagle" "Kuna" "Meridian" "Middleton" "Nampa" "Star"))
(get_attr "city1" "(setq Boise)(done_dialog)")
(get_attr "city2" "(setq Caldwell)(done_dialog)")
(get_attr "city3" "(setq Eagle)(done_dialog)")
(get_attr "city4" "(setq Kuna)(done_dialog)")
(get_attr "city5" "(setq Meridian)(done_dialog)")
(get_attr "city6" "(setq Middleton)(done_dialog)")
(get_attr "city7" "(setq Nampa)(done_dialog)")
(get_attr "city8" "(setq Star)(done_dialog)")
so when I try to use the different set of commands for Caldwell City I get the same ones as I did for Boise City.
Have I done something wrong? Dialog boxes and conditional statements are NEW to me.
Hi Emily,
There may be (probably is) a better way to do this, but the following may get you started:
(defun c:test (/ dcl_id a1)
(setq dcl_id (load_dialog "c:/AutocadCustom/Test2.dcl"));set your filename here
(if (not (new_dialog "CITY" dcl_id)) (exit) )
(set_tile "rc1" "city1") ;sets Boise as the initial selection
(action_tile "accept"
"(progn (setq a1 (get_tile \"rc1\"))
(done_dialog 1)
)"
)
(start_dialog)
(unload_dialog dcl_id)
(cond ((= a1 "city1")(alert "The city is Boise"))
((= a1 "city2")(alert "The city is Caldwell"))
((= a1 "city3")(alert "The city is Eagle"))
((= a1 "city4")(alert "The city is Kuna"))
((= a1 "city5")(alert "The city is Meridian"))
((= a1 "city6")(alert "The city is Middleton"))
((= a1 "city7")(alert "The city is Nampa"))
((= a1 "city8")(alert "The city is Star"))
)
(princ)
)
CITY : dialog {
label = "Select Layer Scheme";
: radio_column {
key = "rc1";
: radio_button {
label ="Boise";
key = "city1";
}
: radio_button {
label ="Caldwell";
key = "city2";
}
: radio_button {
label ="Eagle";
key = "city3";
}
: radio_button {
label ="Kuna";
key = "city4";
}
: radio_button {
label ="Meridian";
key = "city5";
}
: radio_button {
label ="Middleton";
key = "city6";
}
: radio_button {
label ="Nampa";
key = "city7";
}
: radio_button {
label ="Star";
key = "city8";
}
ok_cancel;
}
}
this is just a starting point, and it may need some error checking etc. Post back and I'll try to help as time permits. Make sure to change the path and file name for the dcl in the code to match what you call it.
eleonard
2007-02-27, 01:07 AM
Okay I am completely stuck and frustrated. Sometimes I wonder why I try things that are so far out of my relm.
Anyways I have attached my .lsp and .dcl files. Any help would be greatly appreciated.
I hope you can understand by the dialog box what I am trying to achieve. Based on the 3 area's I need specific information inserted on my dwg.
Emily
Ok, I'll have a look at it tonight, unless someone else chimes in. Hang in there...
Ok, the BIG thing first:
You changed the radio_column to boxed_row, and a boxed_row acts differently.
I changed it to radio_row to return the functionality, but retain your row preference.
As an aside, it is generally better to use a radio_column because the user doesn't have to move the cursor so far, but that is your call.
Will the city be unique, or will you need to select multiple cities?
A radio_row allows/limits us to select only one. If you need multiple, we need to use
a different method.
Same with the notary type and surveyor.
I have taken a guess, based on the insert point, etc., that each will be unique, so see code and dcl attached. I didn't take the time to create the associated directories and blocks, so you need to test it with your functions. You will also need to finish matching the functions to the rest of the cities.
HTH
PS, I also changed a couple of variables; hopefully it will be easier to follow.
eleonard
2007-02-27, 04:28 PM
I greatly appreciate your help! I have loaded the file and I get an error malform list on input. I have searched and can't find the error. I will keep looking but if you could take a look at it again I would appreciate it!
Emily
eleonard
2007-02-27, 05:11 PM
Well I found the cause of my malformed list, but now nothing happens, nothing is inserted but I get this on the command line #<SUBR @096a730c PRINC>. What is this?
And why don't my blocks insert?
eleonard
2007-02-27, 05:19 PM
Never mind about that last one. It helps to finish writing all of the city components.
Never mind about that last one. It helps to finish writing all of the city components.
Oops :Oops: sorry about the missing paren.
Since the only things that are really dynamic in this are the surveyor stamp and type of notary, have you thought about setting up a block/drawing for each city that already has the City Counsel, City Engineer and County Recorder information blocks in them? It would seem easier to me, seeing that those don't change. Also, have you looked at templates?
eleonard
2007-02-27, 06:40 PM
Since the only things that are really dynamic in this are the surveyor stamp and type of notary, have you thought about setting up a block/drawing for each city that already has the City Counsel, City Engineer and County Recorder information blocks in them? It would seem easier to me, seeing that those don't change.
Why should I make things easier :lol: , I like making my life difficult. I may look into that it sure would make a couple things easier.
Also, have you looked at templates?
I didn't want to create templates mainly because I would have to remember to update them as things change. And on top of that users in my office can't seem to start anything with a constructed template. Don't ask why but they can't
Why should I make things easier :lol: , I like making my life difficult. I may look into that it sure would make a couple things easier.
I didn't want to create templates mainly because I would have to remember to update them as things change. And on top of that users in my office can't seem to start anything with a constructed template. Don't ask why but they can't
Let us know if you need more help...
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.