Message 1 of 5
Having Trouble Debugging "stringp nil error"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
(defun c:XDL ( / DwgProps Site# sitename state fletter main stateint directory )
(setq DwgProps (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object))))
(vla-GetCustomByKey DwgProps "Site Number" 'Site#)
(vla-GetCustomByKey DwgProps "Site Name1" 'sitename)
; THESE NEED TO BE SEPERATED OUT DUE TO DIFFERENCES BETWEEN MODIFICATIONS TEAM AND CIVIL TEAM TEMPLATE DWGPROPS SETUP
; - IF "M" IS IN DRAWING NAME, SEARCH FOR "STATE" DRAWING PROP
; USE (STATELIST) TO CONVERT TO STATE INITIALS
; - ELSE SEARCH FOR "SITE STATE" DRAWING PROP
; IF "SITE STATE" EQ. TO 2 CHARACTERS ; PULL INITIALS
; ELSE USE (STATLIST) TO CONVERT TO STATE INITIALS
(if (wcmatch (getvar "dwgname") "*`M*")
(progn
(vla-GetCustomByKey DwgProps "State" 'state)
(setq stateint (cdr (assoc state (statelist))))
)
(progn
(vla-GetCustomByKey DwgProps "Site State" 'state)
(if (= (strlen state) 2)
(setq stateint state)
(setq stateint (cdr (assoc state (statelist))))
)
)
)
(if (eq state "")
(princ "\"State\" drawing property is not filled out. Make sure you are not in a blank template")
(progn
(setq fletter (ascii (substr sitename 1 1)))
(cond
((and (>= fletter 48) (<= fletter 57)) (setq main "0-9"))
((and (>= fletter 65) (<= fletter 66)) (setq main "A-B"))
((and (>= fletter 67) (<= fletter 69)) (setq main "C-E"))
((and (>= fletter 70) (<= fletter 73)) (setq main "F-I"))
((and (>= fletter 74) (<= fletter 77)) (setq main "J-M"))
((and (>= fletter 78) (<= fletter 82)) (setq main "N-R"))
((and (>= fletter 83) (<= fletter 86)) (setq main "S-V"))
((and (>= fletter 87) (<= fletter 90)) (setq main "W-Z"))
)
; LIST OF MAIN FOLDER NAMES ; (0-9) (A-B) (C-E) (F-I) (J-M) (N-R) (S-V) (W-Z)
; USE SITE NAME 1 (DWGPROP) TO DETERMINE "MAIN-FOLDER" ; CREATE A COND TO SET MAIN FOLDER
; - EX. IF SITE NAME IS "A & 10TH STREET" SET MAIN FOLDER TO (A-B)
; - IF FIRST LETTER IN SITENAME IS EQ TO "A" OR "B" - SET MAIN TO "A-B"
; - IF FIRST LETTER IN SITENAME IS EQ TO "C" , "D" OR "E" - SET MAIN TO "C-E"
; - IF FIRST LETTER IN SITENAME IS EQ TO "1" "2" "3" "4" ... SET MAIN TO "0-9"... ETC.
; - MAY WANT TO USE ASCII CHARACTER NUMBER FOR EASE OF CODE...
;(setq stateint (cdr (assoc state (statelist))))
; MODIFICATION TEAM USES FULL STATE NAME AND CIVIL TEAM USES STATE INITIALS IN DRAWING PROPERTIES
;(alert (strcat "X:\\" main "\\" sitename ", " stateint " (" site# ")"))
(setq directory (strcat "X:\\" main "\\" sitename ", " stateint " (" site# ")"))
(Explore directory)
)
)
(princ)
)
(defun Explore ( Directory / Shell result )
(vl-load-com)
(setq Shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(setq result (vl-catch-all-apply 'vlax-invoke (list Shell 'Explore Directory)))
(vlax-release-object Shell)
(not (vl-catch-all-error-p result))
)
(defun statelist ( )
(list
(cons "ALABAMA" "AL")
(cons "ALASKA" "AK")
(cons "ARIZONA" "AZ")
(cons "ARKANSAS" "AR")
(cons "CALIFORNIA" "CA")
(cons "COLORADO" "CO")
(cons "CONNECTICUT" "CT")
(cons "DELAWARE" "DE")
(cons "DC" "DC")
(cons "FLORIDA" "FL")
(cons "GEORGIA" "GA")
(cons "HAWAII" "HI")
(cons "IDAHO" "ID")
(cons "ILLINOIS" "IL")
(cons "INDIANA" "IN")
(cons "IOWA" "IA")
(cons "KANSAS" "KS")
(cons "KENTUCKY" "KY")
(cons "LOUISIANA" "LA")
(cons "MAINE" "ME")
(cons "MARYLAND" "MD")
(cons "MASSACHUSETTS" "MA")
(cons "MICHIGAN" "MI")
(cons "MINNESOTA" "MN")
(cons "MISSISSIPPI" "MS")
(cons "MISSOURI" "MO")
(cons "MONTANA" "MT")
(cons "NEBRASKA" "NE")
(cons "NEVADA" "NV")
(cons "NEW HAMPSHIRE" "NH")
(cons "NEW JERSEY" "NJ")
(cons "NEW MEXICO" "NM")
(cons "NEW YORK" "NY")
(cons "NORTH CAROLINA" "NC")
(cons "NORTH DAKOTA" "ND")
(cons "OHIO" "OH")
(cons "OKLAHOMA" "OK")
(cons "OREGON" "OR")
(cons "PENNSYLVANIA" "PA")
(cons "RHODE ISLAND" "RI")
(cons "SOUTH CAROLINA" "SC")
(cons "SOUTH DAKOTA" "SD")
(cons "TENNESSEE" "TN")
(cons "TEXAS" "TX")
(cons "UTAH" "UT")
(cons "VERMONT" "VT")
(cons "VIRGINIA" "VA")
(cons "WASHINGTON" "WA")
(cons "WEST VIRGINIA" "WV")
(cons "WISCONSIN" "WI")
(cons "WYOMING" "WY")
)
)
Hello all!
I'm having an issue debugging a code that works about 85% - 90% of the time. I randomly will get a "strinp nil" error once in a while which I understand means that a variable is being passed into my string as nil. However, when this happens and I go to debug the code, the error disappears and it works fine.
My steps in debugging the issue are to open the code in VLIDE and step through line by line. This somehow seems to fix the stringp nil error. I was never able to find out which variable was being passed as nil initially. I'm assuming that stepping through like that let's the code be evaluated more? I'm not sure.
Any advice on how I can go about solving this? Thanks in advance!