Jump to content

Recommended Posts

Posted

I have a routine that I'm working on, which is my first attempt using COND and IF, and I'm running into a problem with how to end the routine. Towards the end, I have

 

(IF (EQ YR "N.F.H.A.")

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "")

 

I need it to skip

(setq L3 (getstring t "\nType Flood Panel Number: "))

(setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": "  ))

(SETQ L4 (STRCAT "DATE " FD))

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 ""))

if the statement is true, otherwise continue on. I'm sure this is an easy fix, I'm just not seeing it. Thanks in advance.

 

here is everything

 

(DEFUN c:LF ()

(SETQ CL (GETVAR "CLAYER"))

(command "layer" "M" "FLOOD" "C" "70" "" "L" "BORDER2" "" "S" "FLOOD" "")

(command ".osnap" "NONE")

(setq DS (getvar 'dimscale))

(SETQ TW (* DS 1.3))

(SETQ TH (* DS 0.07))

(setq pt1 (getpoint "\nPick Insertion Point: "))

(SETQ L1 (STRCAT "APPROX. LOCATION"))

(if (eq (setq ZN (getstring  T "\nFlood Zone A, AE or X?: <X> ")) "")

(setq zn "X"))

(COND ((EQ ZN "A")  (setq YR "100"))

     ((EQ ZN "AE")  (SETQ yr "100"))

(t (IF (EQ (setq YR (getstring  T "\n500 or NFHA? <NFHA> : ")) "")

(SETQ YR "N.F.H.A."))))

(COND ((EQ YR "100")  (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR")))

     ((EQ YR "500")  (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR")))

(T (SETQ L2 (STRCAT "ZONE " ZN " " YR ))))

;===============================PAST THIS POINT IS WHERE I'M HAVING THE ISSUE=======================================================

(IF (EQ YR "N.F.H.A.")

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "")

(setq L3 (getstring t "\nType Flood Panel Number: "))

(setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": "  ))

(SETQ L4 (STRCAT "DATE " FD))

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 ""))

(COMMAND "CLAYER" CL)

)

Posted

Thanks Lee Mac for not giving me the solution. I did a little research and got it!

 

(DEFUN c:LF ()

(SETQ CL (GETVAR "CLAYER"))

(command "layer" "M" "FLOOD" "C" "70" "" "L" "BORDER2" "" "S" "FLOOD" "")

(command ".osnap" "NONE")

(setq DS (getvar 'dimscale))

(SETQ TW (* DS 1.3))

(SETQ TH (* DS 0.07))

(setq pt1 (getpoint "\nPick Insertion Point: "))

(SETQ L1 (STRCAT "APPROX. LOCATION"))

(if (eq (setq ZN (getstring  T "\nFlood Zone A, AE or X?: <X> ")) "")

(setq zn "X"))

(COND ((EQ ZN "A")  (setq YR "100"))

     ((EQ ZN "AE")  (SETQ yr "100"))

(t (IF (EQ (setq YR (getstring  T "\n500 or NFHA? <NFHA> : ")) "")

(SETQ YR "N.F.H.A."))))

(COND ((EQ YR "100")  (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR")))

     ((EQ YR "500")  (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR")))

(T (SETQ L2 (STRCAT "ZONE " ZN " " YR ))))

;===============================NOT AN ISSUE ANYMORE!!========================================

(IF (EQ YR "N.F.H.A.")

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "")

(progn (setq L3 (getstring t "\nType Flood Panel Number: "))

(setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": "  ))

(SETQ L4 (STRCAT "DATE " FD))

(COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 "")))

(COMMAND "CLAYER" CL)

)

Posted
Thanks Lee Mac for not giving me the solution. I did a little research and got it!

 

Nice one Clint - well done!

 

A few pointers to help improve your code some more:

 

 

  • Use conditional expressions (if / cond) to allow for null user input when prompting the user (e.g. getpoint)

 

  • strcat is not required unless concatenating two or more strings.

 

  • Use (princ) or (prin1) to suppress the return of the last evaluated expression and exit the command 'cleanly'.

 

  • Consider using a redefined *error* function to reset System Variable values should the user press Esc or the program encounter an error.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...