TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andrew.. on July 16, 2020, 06:52:34 PM

Title: looking for code for opening a read only file without asking
Post by: andrew.. on July 16, 2020, 06:52:34 PM
Hi all.
Hope everyone is doing well with this covid nonsense going on.
Its been a while since ive posted and did any code. im a bit rusty at it.

I am looking for code bypass the alert asking me if i want to open a read only dwg or not.
I once had the code and got it from here, but the search is not finding it.
I hoping someone has one to share.
thanks
Title: Re: looking for code for opening a read only file without asking
Post by: MSTG007 on July 17, 2020, 07:43:50 AM
This is the code I usually use for opening readonly files without the alert. I am sure there is a better way.

Code: [Select]
(defun open_dwg_read_only (ad fna) (if (findfile fna) (vla-activate (vla-open ad fna :VLAX-TRUE)) (alert (strcat fna "                                                                                                                                                                           DWG file do not exist. Please request DWG file to be processed."))))
(open_dwg_read_only (vla-get-documents (vlax-get-acad-object)) "\\\\Server\\Folder\\Drawing.dwg")

Hope this helps.
Title: Re: looking for code for opening a read only file without asking
Post by: MP on July 17, 2020, 01:59:28 PM
1. If SDI = 0:
    (a) What is the desired behaviour if the specified dwg is already open?
    (b) If the dwg is successfully opened should it be made active?

2. If SDI = 1:
    (a) What is the desired behaviour if the specified dwg is already open?
    (b) If the current dwg has unsaved changes should they be saved or discarded?


etc.
Title: Re: looking for code for opening a read only file without asking
Post by: andrew.. on July 20, 2020, 11:27:08 PM
thank you
Title: Re: looking for code for opening a read only file without asking
Post by: vincent.r on July 21, 2020, 01:56:26 AM
(defun tl:Openfilereadonly ( yourfile / )
(vla-open (vla-get-documents (vlax-get-acad-object)) yourfile :vlax-true)
)
Title: Re: looking for code for opening a read only file without asking
Post by: vincent.r on July 21, 2020, 02:27:07 AM
This is the code I usually use for opening readonly files without the alert. I am sure there is a better way.

Code: [Select]
(defun open_dwg_read_only (ad fna) (if (findfile fna) (vla-activate (vla-open ad fna :VLAX-TRUE)) (alert (strcat fna "                                                                                                                                                                           DWG file do not exist. Please request DWG file to be processed."))))
(open_dwg_read_only (vla-get-documents (vlax-get-acad-object)) "\\\\Server\\Folder\\Drawing.dwg")

Hope this helps.

I think this solution is better.