Author Topic: Adding an Alert if dwg is not available  (Read 1497 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding an Alert if dwg is not available
« on: March 20, 2019, 07:59:11 AM »
I have a dialog box that has a button for each county in the state. I do not have all the counties created yet.

How can I place an if statement that allows for a alert box to appear "county dwg is not completed yet..." if the dwg that it is pulling does not exist?

Code: [Select]
(defun c:adams()
(defun open_dwg_read_only (ad fna)(if (findfile fna)(vla-activate (vla-open ad fna :VLAX-TRUE))))
(open_dwg_read_only (vla-get-documents (vlax-get-acad-object)) "\\\\server\\Adams\\Adams_Co_GIS_SPE_SHP.dwg")
)

I have about 10 out of 90 done lol.

Thank you for any pointers.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Adding an Alert if dwg is not available
« Reply #1 on: March 20, 2019, 08:51:53 AM »
How can I place an if statement that allows for a alert box to appear "county dwg is not completed yet..." if the dwg that it is pulling does not exist?

Since you are already testing whether or not the file exists using findfile, simply add an alert expression as the 'else' argument of the if statement.
Code: [Select]
(defun open_dwg_read_only (ad fna) (if (findfile fna) (vla-activate (vla-open ad fna :VLAX-TRUE)) (alert (strcat fna " doesn't exist."))))

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding an Alert if dwg is not available
« Reply #2 on: March 20, 2019, 08:55:35 AM »
Thank you Lee. Something so simple. Seriously thank you!
Civil3D 2020