Will that help?
Trevor Tutt wrote:
>
> There have been several posts by several individuals on this NG
> regarding the ability to open drawings from autolisp in read only mode.
> None of these requests have been responded to.
> Would someone, from Autodesk or otherwise, please respond to this
> request, even if it is just NO.
> Thanks.
--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
(command "_.shell" "attrib +r <yourdwg>")
...and then open it.
Paul Vine
Software QA Engineer
AutoCAD Express Tools
Autodesk, Inc.
http://www.autodesk.com/expresstools
Tony Tanzillo wrote in message <36681235...@worldnet.att.net>...
>You can't do it directly from AutoLISP. You can use
>DOSLIB or (another ARX library that provides a way
>to set file attributes), to set the drawing file's
>attributes to read-only first, then respond to the
>prompt "Would you like to open the file read-only?",
>that you get when you use the "OPEN" command.
>
>Will that help?
>
>Trevor Tutt wrote:
>>
i guess this is just another windmill in my for a better batch plot.
why can't autodesk come up with a way to batch plot without having to open
each and every drawing. better yet, without having to have autocad open?
In your acad.lsp file add the following
(defun s::startup ()
(if (findfile "drive\\:path\\dwgwrite.dat") ;replace drive and path with
path of your choosing.
(progn
(setq dfile (open "drive:\\path\\dwgwrite.dat" "r"))
(setq dwgwrite (read-line dfile))
(setq dfile (close dfile))
(setq dfile (open "drive:\\path\\dwgwrite.dat" "w"))
(write-line "1" dfile)
(setq dfile (close dfile))
(if (= dwgwrite "0")
(command "setvar" "dwgwrite" dwgwrite)
)
)
)
(princ)
)
----------------------------------------------------------------------------
----------------------------
Here is a simple example of a lisp program that will open a drawing Read
Only. If you have added the above to your acad.lsp file.
(defun C:myopen ()
(setq dwgname (getstring "\nEnter drawing to open Read Only:"))
(if (findfile dwgname)
(progn
(setq dfile (open "drive:\\path\\dwgwrite.dat" "w"));replace drive
and path with path of your choosing.
(write-line "0" dfile)
(setq dfile (close dfile))
(command "open" dwgname)
)
(progn
(alert (strcat dwgname " not Found"))
)
)
(princ)
)
Jim Cheeseman
Paul Vine wrote in message <7497u8$et...@adesknews2.autodesk.com>...
The following works for me in a SCRIPT:
..OPEN
P1TS01.DWG
;IF DRAWING IS IN USE (READ-ONLY), OPEN IT ANYWAY SINCE HALF-SIZE SCRIPT
DOESN'T SAVE DWG
(IF(>=(GETVAR"CMDACTIVE")5)(COMMAND"Y")(PRINC))
Jaysen
Bill
Jim Cheeseman wrote in message <749mv8$gj...@adesknews2.autodesk.com>...
Trevor Tutt wrote:
>
> yeah, thats the best option, but it still leaves me with a button to click.
> I was just trying to come up with a batch plot routine / script that would
> run
> even if some of the files were open by other users.
> I could make temporary copies of the files, but that would just slow things
> down.
> (although, the open dialog's "open as read only" does the same thing.
>
> i guess this is just another windmill in my for a better batch plot.
> why can't autodesk come up with a way to batch plot without having to open
> each and every drawing. better yet, without having to have autocad open?
--
Not being all that enthusiastic about DOSLIB,
heres a 'no-crutches' method which should work fine
with native AutoLISP ...
(command ".shell" (strcat "attrib " file-name " +R"))
(command ".open" filename "y")
Writing the selected drawings filename to a file will
allow you to use some simple AutoLISP to reset the files
attributes after its opened in read-only mode. BTW, you
*do* need to reset the file attributes
(command "shell" (strcat "attrib " file-name "-R"))
Personally, I would use VL without hesitation, but for
native AutoLISP this idea just came to mind.
--
Jesse Danes
Senior Draftsman / AutoCAD Admin
Honeywell, Home & Building Controls
Golden Valley, MN
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Just one little note, you might want to add
(command "._shell" (strcat "attrib " file-name "-R"))
somewhere in there, some people might not like having
dozens of read-only drawing files sitting around :)
Paul Vine wrote:
> Or you could try dropping this line into your AutoLISP function:
>
> (command "_.shell" "attrib +r <yourdwg>")
>
> ...and then open it.
Since you're batch processing files, you can't
start AutoCAD with each one, and avoid the dialog
box, because you don't have control at that point.
If on the other hand, you issue the OPEN command
from within AutoCAD, then you can work around the
problem, but that doesn't work in a batch scenario,
since you would have to restart AutoCAD for each
file, or write a script file that contains the
names of all the files.
--
If you're willing to use a script, the following will open read-only
drawings:
FILEDIA 0
CMDDIA 0
EXPERT 5
..OPEN
P1TS01.DWG
(IF(>=(GETVAR"CMDACTIVE")5)(COMMAND"Y")(PRINC))
....
Jaysen
In terms of AutoCAD and drawing files, its most definitely locked down
and the "attrib" command would return an error "Sharing violation"
Therfore, its easy to test the file before attempting to apply
the "attrib", by using the AutoLISP (open) function
(if (setq file_id (open file-name "a"))
(progn
(close file_id)
(command "._shell" (strcat "attrib " filename " +R)))
(prompt "\nFile is currently in use."))
The 'open for appending' will see if the file can be written to
So if the expression returns nil, the files is locked and if it
returns the file handle, its been opened for "a" by your expression.
However unlike the "w", "a" will not wipe all the files contents (be very
carefull not to make a typo here).
This might not be the exact code you might use in your particular
application however, you can see the principle. I wrote a handy
little function (file-in-use) which offers the ability to test
a files status as available for writing or currently locked by
another application with arguments for re-check frequency in seconds
and total timeout period. I forwarded a copy of the code to Reini Urban
and he posted it on his website if you would like to go there and pick up a
copy.
--
Jesse Danes
Senior Draftsman / AutoCAD Admin
Honeywell, Home & Building Controls
Golden Valley, MN
In article <366C1C96...@flash.net>,
-----------== Posted via Deja News, The Discussion Network ==----------
I have written a batch utility for Release 14 that will open your drawings without
disabling access by others. It will execute a user defined script or AutoLISP routine
on each drawing selected. In addition, some routine options like save as R12, R13,
R14, export to dwf, bmp, wmf, etc. are built in and selectable via radio buttons or
check boxes. It will, optionally, open drawings with recover, do a purge all, and
log the drawings it has processed.
It sounds like this can do what you want. By writing a simple script or LISP routine
to create a plotfile from one drawing, this batch routine will take it and execute it
on all of the drawings you select. It does use AutoCAD R14 as its engine.
I can send you a fully functional demonstration version to try, if you will email
your address to me. The demo version will, however, only process 3 drawings in a
batch. Once it is authorized, it will remove this limitation. The demo should prove
whether the program will perform the function that you need.
Sorry to sound like a commercial here, but I thought it might help you with your
dilemma.
Wayne Craig
wayn...@earthlink.net