Jump to content

Recommended Posts

Posted

There is a senior member of our CAD community who is still stuck (mentally, and otherwise) in all things AutoCAD 2006 Land Desktop, and refuses to adopt the CAD Standards implimented last year when my company deployed 2009 :o:? (I know! ... Can you say 'employer's market?!')

 

Adding to the difficulty in working with this person, is that this person, via Windows Explorer, changes the properties of all project related drawings and files to 'Read-Only' so that nobody else can manipulate the drawings, without their expressed knowledge of whom did what, and when, etc. :twisted:

 

Is it possible, using Visual LISP (ActiveX), to identify a means of manipulating the 'Read-Only' property for a drawing?

 

I'm aware of vla-get-readonly, but desire to manipulate this property. Apropos also shows the vlax-vbreadonly function, but I cannot find documentation.

 

As always, thanks for your help in advance!

Posted

So what is to stop someone from simply removing the read-only flag using Explorer?

IOW - why use AutoCAD to manipulate files?

 

More importantly, why is this person allowed to sabotage working files like this?

 

This screams "management problem" - not a technical problem...

Posted
So what is to stop someone from simply removing the read-only flag using Explorer?

IOW - why use AutoCAD to manipulate files?

 

Absolutely nothing.

 

Windows Explorer is how I presently have to do this. However, in doing so, you're now the owner of said files, having been the last person to modify their properties. :geek: Which is fine, it's just unnecessary, as we'd already be the owner of the file when we save the drawing (duh!).

 

As I only work with this person infrequently, I often *forget* that they do this, as I do the *right thing*(?), and work IAW the standards that have been implemented for the last year.

 

As to why do this from AutoCAD, I ask because when I do have to work with this person, it's usually at the request of my boss (one of the VP's) who usually gets handed a hard copy of something, and wants me to make a copy with some changes. So I open the drawing based upon the stamp information, only to see the 'Read-Only' alert.

 

I was only reminded of this today, as I had to email a client some information as illustrated in the example above. Hence the question posed in this thread.

 

More importantly, why is this person allowed to sabotage working files like this?

 

This screams "management problem" - not a technical problem...

 

 

Short answer... Ego. :o Shocking, I know.

 

Long answer (and from the horse's mouth)... This person setup 2006 enterprise wide (layer naming conventions, .arg, .cui, .lsp, directory structure, etc.), and then weren't promoted to Corporate CAD Manager (CCM), so everything the new CCM (external hire in 2007) did thereafter was somehow *wrong*. They've convinced their manager of this, and were basically given free rain to use whatever they wanted, i.e. 2006, as long as they were productive.

 

We're not talking about project revisions for projects that originated in 2006 (I myself hop back now and then), we're talking about projects that were created this week. Alas, I digress....

 

:: Back on topic ::

 

Again, if there's any suggestions, please let me know.

Posted
Again, if there's any suggestions, please let me know.
Meet this guy in the parking lot, with a brick.
Posted
Meet this guy in the parking lot, with a brick.

 

LOL - That won't be necessary. :D

 

They suffer from what Mark Kiker described as being "Too Good For [His] Own Good" and he refuses to anything new (that he hasn't setup :P).

 

Besides, at the rate they keep making other managers angry, oh, how did one of my managers state it... "their days are numbered!" o:)

Posted

When it shows you the "Read-Only" tag, just open the file's directory, remove the "Read-Only" property and do a SaveAs, using the same drawing name.

 

Straight out of my toolbox: opens directory of active drawing:

(defun C:DIRR nil (startapp "EXPLORER" (getvar 'dwgprefix)) (princ))

Posted
When it shows you the "Read-Only" tag, just open the file's directory, remove the "Read-Only" property and do a SaveAs, using the same drawing name.

 

Straight out of my toolbox: opens directory of active drawing:

(defun C:DIRR nil (startapp "EXPLORER" (getvar 'dwgprefix)) (princ))

 

Understood, thanks for the suggestion. :)

Posted

"No [Write Access] for YOU!" :twisted:

Posted
"No [Write Access] for YOU!" :twisted: "You want [write access]? Two dollars."
Posted
"You want [write access]? Two dollars."

 

That's hilarious! :lol:

Posted
....So I open the drawing based upon the stamp information, only to see the 'Read-Only' alert.

 

At this point you have to close the drawing unless you do what Alan suggests - so what is it that you want to do programatically?

 

The only thing that comes to mind is to write your own OPEN command that checks for the read-only flag first, removes it if necessary, then calls the ._Open command...

 

You will need DOSLIB for this example..

 

(setq fn "C:\\My Drawings\\blah\\blah\\mydrawing.dwg")
(if (eq 1 (logand (setq tmp (cdar (dos_attrib fn))) 1))
 (dos_attrib fn (1- tmp))
)
;;; Proceed with opening the drawing

Posted

Hey Renderman,

 

I realise Alan has already posted an example of greater concision of how to show a file in explorer, but this may offer some food for thought of another way:

 

(defun LM:GoToFile ( file / shell )
 (vl-load-com)
 ;; © Lee Mac 2010
 
 (if (vl-file-directory-p (setq file (vl-filename-directory file)))
   (progn
     (setq shell (vlax-create-object "Shell.Application"))
     (vlax-invoke shell 'Explore file)
     (vlax-release-object shell)
   )
 )
)

Also, here is a way to remove the read-only attribute for a file:

 

(defun LM:RemoveReadOnly ( file / fso f )
 (vl-load-com)
 ;; © Lee Mac 2010

 (setq fso (vlax-create-object "Scripting.FileSystemObject"))

 (if (not (zerop (vlax-invoke fso 'FileExists file)))
   (progn
     (setq f (vlax-invoke fso 'GetFile file))
     (vlax-put-property f 'Attributes (boole 4 1 (vlax-get f 'Attributes)))
     (vlax-release-object f)
   )
 )

 (vlax-release-object fso)
)

In both examples, supply the function with a full filename (remember double backslashes to avoid the slashes being interpreted as character escape sequences).

 

Also, you could use something like this to 'mapcar' the above across all files in a folder and subfolders:

 

(defun LM:GetAllFiles ( dir typ )
 (vl-load-com)
 ;; © Lee Mac 2010
 (append
   (mapcar
     (function
       (lambda ( x ) (strcat dir "\\" x))
     )
     (vl-directory-files dir typ 1)
   )
   (apply 'append
     (mapcar
       (function
         (lambda ( x ) (LM:GetAllFiles (strcat dir "\\" x) typ))
       )
       (vl-remove-if (function (lambda ( x ) (wcmatch x "`.,`.`."))) (vl-directory-files dir "*" -1))
     )
   )
 )
)

Hope this helps!

 

Lee

Posted (edited)

Thanks for the thoughtful response, RK.

 

 

 

I had one of three things in mind:

  1. Simply continue as usual
  2. Use a reactor (:vlr-beginDwgOpen, perhaps?) in a similar fashion as you or Alan have described, without re-defining the open command itself.
  3. Or, to write something with ObjectDBX that would (recursively) step through the entire engineering directory structure and change the property programmatically. o:)

The latter being entirely dependent on the property being available as part of an API, from which I have access. :(

Edited by BlackBox
Recursive note
Posted

Lee... While I've not had time to fully digest all of the information given here (from all of the helpful responses), you're recursive function read my mind. :D

 

I'm a former Soldier (Airborne), and in this instance, I believe in Massive [programmatic] Retaliation! :twisted: I'll probably get in trouble for doing something like that, so I'll proceed with caution (of course)! (it just seems so fitting!)

 

That's just great... where's my Wayne's World pic.... Ah, here it is:

Posted
I'm a former Soldier (Airborne), and in this instance, I believe in Massive [programmatic] Retaliation! :twisted: I'll probably get in trouble for doing something like that, so I'll proceed with caution (of course)! (it just seems so fitting!)

 

That's just great... where's my Wayne's World pic.... Ah, here it is:

 

Hehehe give him a dose of his own medicine... :D

Posted

Wrote this a while back, but after seeing yours (Lee), I decided to add a filetype filter.

 

(defun AT:GetAllFiles (dir flt / foo)
 ;; Return list of all files in specified directory (including sub-directories)
 ;; dir - valid directory "c:\\FOLDER"
 ;; flt - filter string for files (nil if not needed) "*.LSP,*.txt"
 ;; Alan J. Thompson, 08.25.10
 (defun foo (d f / l v)
   (foreach x (vl-directory-files d)
     (cond ((vl-position x '("." "..")) nil)
           ((vl-file-directory-p (setq v (strcat d "\\" x))) (setq l (append (foo v f) l)))
           ((wcmatch (strcase v) f) (setq l (cons v l)))
     )
   )
 )
 (vl-sort (foo dir
               (cond ((eq (type flt) 'STR) (strcase flt))
                     ("*")
               )
          )
          (function <)
 )
)

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