ishka Posted March 17, 2015 Share Posted March 17, 2015 Am I missing something here? I have an original code that I would want to make it user choice based, but it seems it does not work as intended when conditions are used. So original code is as: (defun c:esd_gcid ( / GRDREF MAPPATH) (setvar "cmdecho" 1) (setvar "filedia" 0) (setvar "cmddia" 0) (command "layer" "M" "G-NPLT" "") (command "rectang" PAUSE PAUSE) (princ "\nCAD Data...") (setq GRDREF (getstring "Enter Data Type: ")) (setq MAPPATH (strcat "M:\\GIS-CAD\\Cadastre\\TCAD\\DWG\\TCAD" GRDREF)) (command "adedrawings" "AT" MAPPATH "X") (command "adequery" "C" "D" "L" "L" "P" "C" PAUSE "X" "E" "D") (command "adedrawings" "DE" "*" "X") (setvar "cmddia" 1) (setvar "filedia" 1) (princ) ) The modified conditional code is (defun c:esd_gcid ( / GRDREF MAPPATH) (setvar "cmdecho" 1) (setvar "filedia" 0) (setvar "cmddia" 0) (command "layer" "M" "G-NPLT" "") (command "rectang" PAUSE PAUSE) (princ "\nCAD Data...") (setq GRDREF (getstring "Enter Data Type: ")) (cond ( (= GRDDEF "TCAD") (setq MAPPATH (strcat "M:\\GIS-CAD\\Cadastre\\TCAD\\DWG\\" GRDREF))) ( (= GRDDEF "TCAD-TEXT") (setq MAPPATH (strcat "M:\\GIS-CAD\\Cadastre\\TCAD\\DWG\\" GRDREF))) ) (command "adedrawings" "AT" MAPPATH "X") (command "adequery" "C" "D" "L" "L" "P" "C" PAUSE "X" "E" "D") (command "adedrawings" "DE" "*" "X") (setvar "cmddia" 1) (setvar "filedia" 1) (princ) ) What am I losing in the process? Is the GRDREF not stored anywhere before it is passed to the condition? What I try to achieve is based on the user answer to load specific data using the mapattach. I don't want to make individual lisp commands for each type of data. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 17, 2015 Share Posted March 17, 2015 You are assigning the return of getstring to a variable GRD[highlight]R[/highlight]EF but testing the value of GRD[highlight]D[/highlight]EF. However, the conditional is redundant since you appear to be concatenating the same path, whatever the value of GRDREF. Quote Link to comment Share on other sites More sharing options...
ishka Posted March 17, 2015 Author Share Posted March 17, 2015 You are assigning the return of getstring to a variable GRD[highlight]R[/highlight]EF but testing the value of GRD[highlight]D[/highlight]EF. However, the conditional is redundant since you appear to be concatenating the same path, whatever the value of GRDREF. I see. I guess it was my user error then there. The GRDDEF should have been the GRDREF. That was my intention, but I guess fat fingers do good job of messing. Thanks for pointing out my error on coding. This was actually my first ever attempt at writing a lisp routine. So I am on the right track. Thanks a lot Lee. Your posts and replies are always on target Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 17, 2015 Share Posted March 17, 2015 You're welcome - Good luck with the coding! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 18, 2015 Share Posted March 18, 2015 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.