Jump to content

Script to open read only and plot drawings by lisp


CloudJack

Recommended Posts

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...