BeginCommand - Detect modifications

BeginCommand - Detect modifications

Anonymous
Not applicable
356 Views
6 Replies
Message 1 of 7

BeginCommand - Detect modifications

Anonymous
Not applicable
I have a logic in my application witch determines if the current user has modification rights on the drawing. If the user does not have modification rights, I use BeginCommand to cancel all commands, so that the user cannot even move an object in the drawing. The draw back is that all commands that are used to navigate the drawing (Zoom, Pan, Activating Views, UCSs and many more) don't work eighter.

I am looking for a way to detect if a command will apply modifications to the drawing (other than the active viewport). It would also be important to be able to do this in the BeginCommand event, not the EndCommand event.

If this is not possible, is it possible to make a drawing Read-Only to the point that the user cannot event move or modify any objects in the drawing; not being able to save the drawing is not enought....

Thx.
0 Likes
357 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
why not use a Select Case statement in the BeginCommand event allowing the
viewing commands and not the others? just a thought ...

wrote in message news:5821746@discussion.autodesk.com...
I have a logic in my application witch determines if the current user has
modification rights on the drawing. If the user does not have modification
rights, I use BeginCommand to cancel all commands, so that the user cannot
even move an object in the drawing. The draw back is that all commands that
are used to navigate the drawing (Zoom, Pan, Activating Views, UCSs and many
more) don't work eighter.

I am looking for a way to detect if a command will apply modifications to
the drawing (other than the active viewport). It would also be important to
be able to do this in the BeginCommand event, not the EndCommand event.

If this is not possible, is it possible to make a drawing Read-Only to the
point that the user cannot event move or modify any objects in the drawing;
not being able to save the drawing is not enought....

Thx.
0 Likes
Message 3 of 7

Anonymous
Not applicable
Sorry, I have to say that what you're doing makes no sense,
and if it's not your money that you're wasting on this, then
you should consider stopping.

It really doesn't matter what a user without 'modification
rights' does in the drawing editor, if they can't save the file
because the OS doesn't give them the rights to do that.

Please don't waste someone else's money with this soft
of nonsense. You don't stop a user from making changes
to a file, because even if they don't have rights to modify
the file, they do have the right to make changes to the
copy of the file that is open in the editor for a variety of
reasons which you just haven't realized yet (that's right,
the file open in the editor is logically, a copy of the file
on disk that was opened, and the disk file is what a user
may not have rights to change).

Rights to modify files are enforced by the OS, not by
VBA macros.

Oh, and sorry, there's no way to do what you seek anyway.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5821746@discussion.autodesk.com...
I have a logic in my application witch determines if the current user has modification rights on the drawing. If the user does not have modification rights, I use BeginCommand to cancel all commands, so that the user cannot even move an object in the drawing. The draw back is that all commands that are used to navigate the drawing (Zoom, Pan, Activating Views, UCSs and many more) don't work eighter.

I am looking for a way to detect if a command will apply modifications to the drawing (other than the active viewport). It would also be important to be able to do this in the BeginCommand event, not the EndCommand event.

If this is not possible, is it possible to make a drawing Read-Only to the point that the user cannot event move or modify any objects in the drawing; not being able to save the drawing is not enought....

Thx.
0 Likes
Message 4 of 7

Anonymous
Not applicable
Tony, you should try to be more positive:)

How about this:

'~~~~START CODE
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "ZOOM" Or _
CommandName = "PAN" Then
'allow command
Else
'stop your command however you are
End If
'~~~~END CODE

MAN! That was hard.
Sorry it's impossible to achieve~ LOL
You just need to make a list of commands you will allow and use the above logic.
0 Likes
Message 5 of 7

Anonymous
Not applicable
Good point "rstrandmark". Realy, Tony.... Come on. Its not because AutoCAD doesn't do something that its not possible or not worth doing.... I expected a bit more of an open mind from you!

Since our drawings are not DWGs themselfs, but dynamicly generated drawings from a DB that are simply outputed to DWG for backup reasons, it makes perfect sence to do what I am doing. The user never directly opens a DWG (he doesn't even know that there is a DWG), thus modification rights must be handled directly at the user's input. OS restrictions are completly obsolete in this case.

I got it to work pretty well.
If you care to know how, here it is.
[code]
Public Sub HandleBeginCommand(CommandName As String)

On Error GoTo ErrorHandler

Dim vAnnCommandName As String

If UCase$(Left$(CommandName, 7)) <> "-VBARUN" Then
If CI_CurrentWindowSession.UserHasModificationRights() = False Then
vAnnCommandName = CommandName
vAnnCommandName = Replace(vAnnCommandName, "_", "")
vAnnCommandName = Replace(vAnnCommandName, "-", "")
vAnnCommandName = Replace(vAnnCommandName, ".", "")
vAnnCommandName = UCase$(vAnnCommandName)

If mROCommandsToBeUndoed.Exists(vAnnCommandName) = True Then
Ci_ThisDrawing.SendCommand Chr(27) & "U" & vbCr
ElseIf mAllowedROCommands.Exists(vAnnCommandName) = False Then
Ci_ThisDrawing.SendCommand Chr(27) & Chr(27)
End If
End If
End If

Exit Sub
ErrorHandler:
'-------------------------Error Handler---------------------------------
iFM_ErrHandler.AppendParent "Ci_GraphicalInterface", "HandleBeginCommand", Erl
iFM_ErrHandler.CreateSystemMessage True
'-------------------------Error Handler---------------------------------

End Sub


Private Sub BuildROCommandList()

On Error GoTo ErrorHandler

'This sub builds a list of all commands that are available in a
''drawing that is read only (User Does Not Have Modification Rights)
''and all commands that need to be UNDOed in Read-Only mode

Set mAllowedROCommands = New Dictionary
mAllowedROCommands.Add "PURGE", ""
mAllowedROCommands.Add "PAN", ""
mAllowedROCommands.Add "ZOOM", ""
mAllowedROCommands.Add "LAYERP", ""
mAllowedROCommands.Add "LAYMCUR", ""
mAllowedROCommands.Add "LAYER", ""
mAllowedROCommands.Add "LAYWALK", ""
mAllowedROCommands.Add "LAYISO", ""
mAllowedROCommands.Add "LAYVPI", ""
mAllowedROCommands.Add "LAYUNISO", ""
mAllowedROCommands.Add "LAYOFF", ""
mAllowedROCommands.Add "LAYON", ""
mAllowedROCommands.Add "LAYFRZ", ""
mAllowedROCommands.Add "LAYTHW", ""
mAllowedROCommands.Add "LAYLCK", ""
mAllowedROCommands.Add "LAYULK", ""
mAllowedROCommands.Add "DIST", ""

Set mROCommandsToBeUndoed = New Dictionary
mROCommandsToBeUndoed.Add "E", ""
mROCommandsToBeUndoed.Add "ERASE", ""
mROCommandsToBeUndoed.Add "X", ""
mROCommandsToBeUndoed.Add "EXPLODE", ""

Exit Sub
ErrorHandler:
'-------------------------Error Handler---------------------------------
iFM_ErrHandler.Handle "Ci_GraphicalInterface", "BuildROCommandList", Erl
'-------------------------Error Handler---------------------------------

End Sub
[/code]

You oubviously need to call the BuildROCommandList before. But this has a pretty good look and feel.
......

And please Tony, keep unconstructive comments to yourself. You did not need to attack me and tell me I am waisting someone's money. Mabee just letting me know of the normal way to manage drawing access rights TO SEE IF IT WOULD MATCH MY REQUIREMENTS......

It is why we are AutoCAD customizers... to do what AutoCAD CANNOT do, no?

Sorry Tony but I had to say this.

No hard feelings?
0 Likes
Message 6 of 7

Anonymous
Not applicable
>>(he doesn't even know that there is a DWG)

he must be pretty stupid if he can't see what is staring him in the face
0 Likes
Message 7 of 7

Anonymous
Not applicable
That's not what I ment. The user never "OPENS" a DWG, nor does he saves it or closes it. The equivalent of these operations are done with stored procedures in our SQL DB. It generates an XML of objects that are then created in ModelSpace (of whatever drawing). The user can modify it and then the system saves the changes to the object to the database. A close simply empties the ModelSpace and block definitions (A purge if you will).

Thats what I ment by :
>>(he doesn't even know that there is a DWG)
0 Likes