Drawing Object

Drawing Object

Anonymous
Not applicable
606 Views
8 Replies
Message 1 of 9

Drawing Object

Anonymous
Not applicable
I have an appl. that opens a drawing as read only so users can copyclip some blocks. I need a way of closing this drawing without being prompted to save changes. I thought in saving this document on a variable and then using its EndCommand event, but I can't find a way of achieving it. Can someone give some ideas or a better solution? Thanks in advance.
0 Likes
607 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
The first arg of the Close method is SaveChanges. Set to False to prevent prompting. The drawing will be closed without saving. -- ---- Ed ---- "HJohn" wrote in message news:22560602.1084975193212.JavaMail.jive@jiveforum2.autodesk.com... I have an appl. that opens a drawing as read only so users can copyclip some blocks. I need a way of closing this drawing without being prompted to save changes. I thought in saving this document on a variable and then using its EndCommand event, but I can't find a way of achieving it. Can someone give some ideas or a better solution? Thanks in advance.
0 Likes
Message 3 of 9

Anonymous
Not applicable
Thanks Ed, I could do that if I were to close the opened "Read Only" file from the code. The file is being closed by the user. At this point the code(application) is terminated as soon as the file is opened. I could use thisdrawing object of the project to handle this. Is there a way of saving the drawing object into a variable and then using its events? I want the user to finish the copyclip command and then intersect an event to handle the closing, all of this from the same app. module, without adding additional code to the thisdrawing.
0 Likes
Message 4 of 9

Anonymous
Not applicable
The help says that the Close event is initiated as soon as acad recieves a request to close a doc. In my testing, this is not true. If the dwg has changes, you are first prompted to save via a dialog. And the help also states that if there is a modal dialog open, no events are fired. Therfore, events won't work in this case. You could redefine the close command to first check if the dwg is read-only (I havn't tested this). But then you stand the possiblilty of loosing work. You could also create a temporary command via code that would close the doc and train the users to close using this rather than just clicking on the X. -- ---- Ed ---- "HJohn" wrote in message news:23216564.1084977620181.JavaMail.jive@jiveforum1.autodesk.com... Thanks Ed, I could do that if I were to close the opened "Read Only" file from the code. The file is being closed by the user. At this point the code(application) is terminated as soon as the file is opened. I could use thisdrawing object of the project to handle this. Is there a way of saving the drawing object into a variable and then using its events? I want the user to finish the copyclip command and then intersect an event to handle the closing, all of this from the same app. module, without adding additional code to the thisdrawing.
0 Likes
Message 5 of 9

Anonymous
Not applicable
Thanks again. I don't want to complicate things. I tried to use the thisdrawing object to handle the closing, I thought it was easy, but I don't know how to do it. How can I prevent the save changes dialog from showing during the closing, since it is a read only drawing?
0 Likes
Message 6 of 9

Anonymous
Not applicable
That's what I was trying to say. Using vba, you can't "override" the save change dialog in your situation. The only other thing I can think of is to reset the DBMOD sysvar to 0 in the ObjectModified event. For that, you need askdunsupp200x.arx. Search this ng for a copy for your version of acad. Note again, that this can be dangerous in that users may not be able to save their changes if they really wanted to. I would include a check on the readonly prop to at least limit this behavior to readonly dwgs. -- ---- Ed ---- "HJohn" wrote in message news:6986043.1084983704150.JavaMail.jive@jiveforum1.autodesk.com... Thanks again. I don't want to complicate things. I tried to use the thisdrawing object to handle the closing, I thought it was easy, but I don't know how to do it. How can I prevent the save changes dialog from showing during the closing, since it is a read only drawing?
0 Likes
Message 7 of 9

Anonymous
Not applicable
Thank you Ed for your help. I don't want to rethink this, so I am going to leave it just the way it is. It is one of those things that seem very easy but turn out to be complicated.
0 Likes
Message 8 of 9

Anonymous
Not applicable
I wouldn't mess with redefining the close command either. Give some more thought to popping a toolbar button when the user switches to the read-only dwg. I don't have time to show you how to create a toolbar button, but replace the msgbox code with code that displays a toolbar button in the middle of the screen. 'Where Doc is a Document variable declared With Events Private Sub Doc_Activate() If Doc.ReadOnly = True Then MsgBox ("This dwg is read-only") 'Display a 'Close Me' toobar button here 'that uses the Close method with the SaveChanges arg =False End Sub -- ---- Ed ---- "HJohn" wrote in message news:13386698.1084996678406.JavaMail.jive@jiveforum1.autodesk.com... Thank you Ed for your help. I don't want to rethink this, so I am going to leave it just the way it is. It is one of those things that seem very easy but turn out to be complicated.
0 Likes
Message 9 of 9

Anonymous
Not applicable
Ed could you see if you could make something like this work. I always get "Drawing is busy". I tried a few things but I don't have much experience with object events. Thanks in advance.

Option Explicit
Public WithEvents Dwg As AcadDocument
Dim DwgName As String
Dim CurrDwg As String
Private Sub CmmdCancel_Click()
Set Dwg = Nothing
Application.Documents.Item(DwgName).Close False
Unload Me
End Sub

Private Sub UserForm_Activate()
CurrDwg = ThisDrawing.name
End Sub

Private Sub CmmdGetDrawing_Click()
Dim NewDwg As String

NewDwg = "C:\Documents and Settings\HJohn\Desktop\Drawing1.dwg"

Set Dwg = Application.Documents.Open(NewDwg, True)

DwgName = Dwg.name

Me.Hide

End Sub

Private Sub Dwg_EndCommand(ByVal CommandName As String)

If CommandName = "COPYCLIP" And Dwg.ReadOnly = True Then
Application.Documents.Item(CurrDwg).Activate
Me.Show
Call CmmdCancel_Click
End If
End Sub
0 Likes