Jump to content

Having Trouble with a Macro


Bill Tillman

Recommended Posts

I am trying to run the following macro to open a drawing file, then load and execute a LISP file.

 

^C^CFILEDIA;0;OPEN;"\\a_long_novell_path\MyDrawingFile.dwg";FILEDIA;1;(load "//a_long_novell_path/MyLispFile.lsp");TEST;

I have this in a custom menu item but when it runs it pauses with the drawing file being loaded in a Dynamic Input window on the screen. When I press enter it loads the drawing but then stops action. It does not load and execute the LISP file. I have tried placing two semicolons after the drawing name to force another but still get the same results.

Link to comment
Share on other sites

Thanks BigAl, that does make sense. I found some additional typos....darn those novell server paths, 75 characters long so it's easy to make a typo. I have to use UNC because the various departments running this all have different drive mappings. So much for the strict enforcement of standards. I also had to add a "Y" in the script file because the drawing file is Read-Only and it was pausing to confirm if I wanted to open it or not. This happened even when I set EXPERT to level 5. Anyway, it's working now and we're all off to automated bliss once more. Thanks.

Link to comment
Share on other sites

Okay, I thought this one was resolved but apparently there is another issue with that "Y" I installed. Last week I was running the script and AutoCAD 2013 was pausing at the OPEN command asking me to confirm the file to open this Read-Only file. So I added a new line which contained only the letter "Y" and it all started working. I tested this at other users' machines, 2009, 2013, 2014 and 2014 Mechanical users and it all worked well. Today, when I run the script it opens the drawing file but then gives me an error Unknown command "Y". I checked and FILEDIA is set to 1, so I changed it to 0 but got the same results. It appears that I'm missing something in another environment variable. I also experimented with EXPERT setting it all the way to 5 and then back to 0 but nothing changed.

 

The drawing I'm opening is marked Read-Only and that's the prompt I'm seeing. I just tested this at some other locations at it's running fine there. If I comment out the "Y" it has the reverse affect on all of us, that is it starts running on my machine but failing at all the others. Here is the script file as it stands this morning:

_.OPEN "\\a_very_long_novell_path\MyDwgFile.dwg"
Y
(LOAD "//a_very_long_novell_path/MyLispFile.lsp")
MyLispCmd

Link to comment
Share on other sites

A lot more longwinded but it would be possible to check if file is actually set to "read only" so your script would check for this and then run another script readonlyopen or script notreadonly. Probably a start lisp then script. Try to find under VL file commands

 

Done !!!

 

; ORIGINAL CODE
; STIG.MADSEN @ AUGI FORUMS
; Shortened to give read only flag which is 1 
(setq aFile (getfiled "" "" "" 4))
         (setq fso (vlax-create-object "Scripting.FilesystemObject"))
         (setq oFile (vlax-invoke fso 'GetFile aFile))
 
 (SETQ READONLY (vlax-get-property oFile 'Attributes)) ; 1 read-only 0 read-write
 (IF (= READONLY 1)
  (ALERT "FILE IS READ ONLY") ; set gloabl variable or run script here exits then
  (ALERT "FILE IS NOT READ ONLY"
 )   
    (vlax-release-object oFile)
    (vlax-release-object fso)
   )
 )
 (princ)

Edited by BIGAL
Link to comment
Share on other sites

Thanks again BIGAL. I'm trying to discern what happened with my settings. What I need is for the file to always remain read-only. That way none of the "blankety-blank" users can screw with it without actually committing the crime or changing it's properties first. On Monday, this was working perfectly for everyone. And the other users in the office still can get the script to run without them getting a prompt about the file being read-only. This is an automated process and it needs to allow the users simply to click on the Menu choice which will load the drawing, run the LISP and then get out of their way. Which it was doing. But now for some reason unknown to myself, my computer will no longer run it without complaining about the "Y". The other users are not seeing this. Now, being the only developer in this department, my system is often getting tweaked and messed around with so I'm pretty sure it was something I did. But I can't seem to figure it out. I'll keep digging.

Link to comment
Share on other sites

Just guessing here but could this be something to do with the .dwl file?

 

Are you the first to open the drawing so you are not getting the 'file already open' flag whereas the others opening the file after you are getting this flag and need the 'y' to open it read only and continue.

Link to comment
Share on other sites

This was a mystery....and now, finally I checked what I guess I should have checked in the beginning. The drawing file was marked as Read-Only, which I did myself to keep from having a user accidentally overwrite it. In the meeting this morning everyone, all 10 of the users in this department swore on the souls of their children that no one touched it. Well some of them must not have children because when I finally broke down and checked....you guessed it, someone had taken the Read-Only setting off of the file. This is why my script was getting confused with the "Y". Now why the other users in the department were not getting the same results, I still cannot say. But it is working again like it's supposed to. The file is not only back to Read-Only but it's been isolated in a folder on the server where no one except your's truly can change it. Live and learn.

 

And yes nuckcad, I think you have a valid point there as to why it would work for others and not for me. Since I was the one with it opened most of the time, the others would have encountered a Read-Only situation. But when I closed it and no one else had it opened and since someone had taken the Read-Only attribute off of it without my knowledge, that makes sense. But who removed the Read-Only attribute will remain a mystery because no one feels like confessing to the crime. The file is totally locked away now so if it happens again at least I will know I did it.

Link to comment
Share on other sites

The bit of the code I left out actually changed the file to be read only if it was not so they may think there smart changing it to read, I found it via google, so you can still do the work around as you can set it before the Autocad Open hidden form the user. It may be a problem if you have it open, checking for dwl is not a good idea as the guys here use crash exit a lot I yell at them and this leaves the dwl behind so if you check for that it will say file locked but its not.

 

;I think its to read only would have to google again
(vlax-put-property oFile 'Attributes 1)

Link to comment
Share on other sites

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