Jump to content
CloudJack

Script to open read only and plot drawings by lisp

Recommended Posts

CloudJack

I create a script:

(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) "C:/TEST/PlotDrawing.dwg" :VLAX-TRUE)) (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y

 

However, the command [ (load "C:\\TEST\\PDF.lsp") (c:pdf) _close ] do not run on PlotDrawing.

 

PDF.lsp is just using -plot to plot pdf by setting A3 size and plotter which are different from drawing default.

 

I would like to open the drawing by read only then using lisp to plot drawings. (in case of any other have opened the drawing)

Share this post


Link to post
Share on other sites
BIGAL

There was a way of testing for read only in case of dwg alerady open do a search. Change your method to a script may be better, the script can have lisp in it like your (load "pdf") etc this will run over multiple drawings open and closing in sequence.

Share this post


Link to post
Share on other sites
CloudJack
There was a way of testing for read only in case of dwg alerady open do a search. Change your method to a script may be better, the script can have lisp in it like your (load "pdf") etc this will run over multiple drawings open and closing in sequence.

 

I have already used Script file to run my code

Originally, I use "open" to script file

open "C:\TEST\PlotDrawing.dwg" (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y

 

However, when someone is open the drawing already, the script will stop and ask "Open file read only? (Y)". After manually enter "Y", the script will continue.

 

The "Open file read only? (Y)" will only show when someone opened the drawing.

 

I tried to change like this

open "C:\TEST\PlotDrawing.dwg" Y (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y

 

When no one is opening the drawing, It will stop to show [Y Unknown command "Y". Press F1 for help.]

 

Therefore, I change the code to the first post

(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) "C:/TEST/PlotDrawing.dwg" :VLAX-TRUE)) (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y

 

How can I dual with this issue?

Share this post


Link to post
Share on other sites
BIGAL

Just a quick maybe check if DWL* exists for the dwg name to be opened, if so that says some one has it open and need the "Y". Only problem is if you exit using red cross or it crashes you can get DWL's left behind could check date also as a double check. I clean up dwl's all the time on our server.

Share this post


Link to post
Share on other sites
CloudJack

Thank for the tips.

 

I have tried again in below scripts but failure.

(defun _FileOpen-p ( filename / f ) (if (setq f (open filename "a")) (close f) t))
(setq ofile "C:\TEST\PlotDrawing.dwg")
(if (_FileOpen-p ofile)
open "C:\TEST\PlotDrawing.dwg" Y (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y
open "C:\TEST\PlotDrawing.dwg" (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y
)

(defun _FileOpen-p ( filename / f ) (if (setq f (open filename "a")) (close f) t))
(setq ofile "C:\TEST\PlotDrawing.dwg")
open "C:\TEST\PlotDrawing.dwg" (if (_FileOpen-p ofile) Y) (load "C:\\TEST\\PDF.lsp") (c:pdf) _close Y

 

how could I do the check while the script is running?

Share this post


Link to post
Share on other sites
BIGAL

Think about this using the vla method you check if TRUE but what about False so need the line twice read-only or not.

Share this post


Link to post
Share on other sites
CloudJack
Think about this using the vla method you check if TRUE but what about False so need the line twice read-only or not.

 

I dont know how to using vla method to check.

 

In my code, it is stop the script after open the drawings.

(defun _FileOpen-p ( filename / f ) (if (setq f (open filename "a")) (close f) t))
(setq ofile "C:\TEST\PlotDrawing.dwg")
(if (_FileOpen-p ofile) (progn (vla-activate (setq adoc (vla-open (vla-get-documents (vlax-get-acad-object)) "C:\TEST\PlotDrawing.dwg" :VLAX-TRUE))) (vla-sendcommand adoc "(load "C:\\TEST\\PDF.lsp")\r") (vla-sendcommand adoc "(c:pdf)\r")))

 

The process is:

1. In active drawing A to load .scr file.

2. open PlotDrawing.dwg and activate it

3. nothing happen

4. return tab to drawing A

5. the script continue to run (load "C:\\TEST\\PDF.lsp") and (c:pdf) on drawing A

 

Can anybody provide some code for me to dual with this issue?

 

Thank you all.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×