Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OPEN READ ONLY: PLEASE RESPOND

2 views
Skip to first unread message

Tony Tanzillo

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to
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:
>
> 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 */
/*********************************************************/

Trevor Tutt

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to

Paul Vine

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to
Or you could try dropping this line into your AutoLISP function:

(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:
>>

Trevor Tutt

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to
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?


Jim Cheeseman

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to
Try this

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>...

Jaysen Long

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to

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 Farmer

unread,
Dec 4, 1998, 3:00:00 AM12/4/98
to
Jim,
There's one big problem with this. System variable "DWGWRITE" is no
longer supported in R14.

Bill

Jim Cheeseman wrote in message <749mv8$gj...@adesknews2.autodesk.com>...

Tony Tanzillo

unread,
Dec 5, 1998, 3:00:00 AM12/5/98
to
Trevor - how are you doing batch process? E.g., with a
batch file, script, or what?

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?

--

jda...@my-dejanews.com

unread,
Dec 6, 1998, 3:00:00 AM12/6/98
to
In article <36681235...@worldnet.att.net>,

Tony Tanzillo <tony.t...@worldnet.att.net> wrote:
> 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?

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

jda...@my-dejanews.com

unread,
Dec 6, 1998, 3:00:00 AM12/6/98
to
In article <7497u8$et...@adesknews2.autodesk.com>,

"Paul Vine" <paul...@autodesk.com> wrote:
> Or you could try dropping this line into your AutoLISP function:
>
> (command "_.shell" "attrib +r <yourdwg>")
>


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 :)

Trevor Tutt

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
I would prefer to use just a script.
the batch plot utility (vb i think) will not plot to file, and unfortunately that
is what i need. we have a reprograph copmany set up in our offices with an oce
9800. we currently use a third party package that sends a plot job to the plot
server and the repro person plots the files. this is not connected to the
network in any way, nor do i think that it will be (their toys, their rules)
I have made the observation that no one can plot a dwg like AutoCAD and I am just
looking for a better way of sending multiple plots.
this should probably be moved to the print/plot ng.

Trevor Tutt

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
does this work if someone has the file open?

Paul Vine wrote:

> Or you could try dropping this line into your AutoLISP function:
>
> (command "_.shell" "attrib +r <yourdwg>")
>

> ...and then open it.


Trevor Tutt

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
is there a way through vb or arx that I can cause a drawing to be opened read
only by the same process as it is done from the open dialog box? I guess it is
really just making a copy isn't it. making copies just seems to cause
unnecessary copying across the network in regards to batching a large number of
files.
who would we have to pay off at Autodesk to have them implement
batch plotting from within autocad that will give us every bit of functionality
from the existing plot function, but also allow us to plot more than one file at
a time without having to actually open each dwg? Ideally, this would be
functional without autocad running at all ( it could still have to require
autocad to be installed to function if there were any concerns about piracy )
Ive just hit the wall in regards to a good plotting solution. only autocad can do
it right, but only the third parties can do it efficiently.


Tony Tanzillo

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
You should probably find someone who can make the
changes to the batch plot program that will plot
to file. It shouldn't require much, but I'm not
fluent in VB, so I can't help you.

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.

--

Jaysen Long

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Trevor Tutt wrote:
>
> I would prefer to use just a script.
> the batch plot utility (vb i think) will not plot to file, and unfortunately that
> is what i need. we have a reprograph copmany set up in our offices with an oce
> 9800. we currently use a third party package that sends a plot job to the plot
> server and the repro person plots the files. this is not connected to the
> network in any way, nor do i think that it will be (their toys, their rules)
> I have made the observation that no one can plot a dwg like AutoCAD and I am just
> looking for a better way of sending multiple plots.
> this should probably be moved to the print/plot ng.
>

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

jda...@my-dejanews.com

unread,
Dec 9, 1998, 3:00:00 AM12/9/98
to
Generally speaking, it would depend on if the parent application
which has the file open, has it open as read-only or as read/write
and if it locks the file down via the operating system.

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 ==----------

Wayne Craig

unread,
Dec 18, 1998, 3:00:00 AM12/18/98
to Trevor Tutt
Trevor,

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

0 new messages