Author Topic: looking for code for opening a read only file without asking  (Read 1587 times)

0 Members and 1 Guest are viewing this topic.

andrew..

  • Newt
  • Posts: 24
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

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: looking for code for opening a read only file without asking
« Reply #1 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.
Civil3D 2020

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: looking for code for opening a read only file without asking
« Reply #2 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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

andrew..

  • Newt
  • Posts: 24
Re: looking for code for opening a read only file without asking
« Reply #3 on: July 20, 2020, 11:27:08 PM »
thank you

vincent.r

  • Newt
  • Posts: 101
Re: looking for code for opening a read only file without asking
« Reply #4 on: July 21, 2020, 01:56:26 AM »
(defun tl:Openfilereadonly ( yourfile / )
(vla-open (vla-get-documents (vlax-get-acad-object)) yourfile :vlax-true)
)

vincent.r

  • Newt
  • Posts: 101
Re: looking for code for opening a read only file without asking
« Reply #5 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.