Jump to content

Recommended Posts

Posted

I'm not expecting an answer here but maybe somebody would like to comment.

 

(This is partly LISP, partly script.)

 

I have a script file to print lots of drawings. This works well but I always set SDI=1 before we start as I don't like 500+ files open at one time. No problem there, I usually work in SDI mode anyway. However I have tweaked the script generator as a co-worker would like SDI reset at the end. No problem, add the following lines to the start and end of the script.

 

(setq SDIMode (getvar "SDI"))
....
(setvar "SDI" SDIMode)

tbh, it wasn't SDIMode but I can't remember what I used but it is relevant.

 

However, when the script got to the paper size

A3 (297 x 420 mm)

the script was exited and AutoCAD expeted the next command (m) to be an instruction. I tried putting quote marks around the paper size to no affect.

 

I finally "corrected" it by changing the variable name to "mySDI".

 

As I say, not expecting an answer but has anybody come across this behaviour before?

 

 

 

Actually, I am reminded of anther oddity we once had. We had the floor plan drawing that ALWAYS plotted rotated by 90 degrees. We eventually renamed it and it plotted correctly.

Posted

The variable is lost since each drawing has its own namespace; that it, you set it in one namespace and attempt to restore it in other one, where isn't available.

I see two workarounds:

 

  1. Use the blackboard, a common namespace available to all drawings. Please check the VL-BB-SET and VL-BB-REF functions.
  2. Set the SDI system variable based on user name:

(if (member (getenv "USERNAME") '("User1st" "User2nd")) (setvar "SDI" 0))

Posted

thanks for that comment, however it does appear to work as it is. The "problem" I had was that the script fell over in the first drawing at a particular line. When I renamed the variable it all worked as expected.

 

I am looking to rework the routine to run in VB.Net but for now it is a simple script with just the 2 LISP statements and don't really want to make it any more complicated.

Posted

MSasu,

 

I have now looked at (vl-bb... and can see that it is a better option than the way I was doing it.

 

I have altered my code and sent it away for testing.....

Posted
As I say, not expecting an answer but has anybody come across this behaviour before?
The behaviour you describe simply is not possible.;):P:lol: Seriously, though, SDI does not invoke any input help in my 2012, yet it does work as a command. Hmmm. I wonder if there are any other 'undocumented' SDI-ish commands that you might have inadvertently run across in your endeavours. Your original choice may have been quite relevant. If only you could recall exactly what you had...
Posted (edited)

The behaviour you describe simply is not possible.;):P:lol:

 

I respectfully disagree... More on that below.

 

Seriously, though, SDI does not invoke any input help in my 2012, yet it does work as a command. Hmmm. I wonder if there are any other 'undocumented' SDI-ish commands that you might have inadvertently run across in your endeavours. Your original choice may have been quite relevant. If only you could recall exactly what you had...

 

SDI (Single Drawing Interface) is a System Variable, only recently undocumented, despite remaining functional was heavily used in Civil 3D's predecessor Land Desktop.

 

The ability to enter the SDI Command, yields the exact same result as setting the system variable via LISP:

(setvar 'sdi 1)

 

... Either of which, illustrated by Autodesk's Drawing Tab plug-in being enabled/disabled when SDI is 0 or 1, respectively, via SystemVariableChanged Event.

 

I'm not expecting an answer here but maybe somebody would like to comment.

 

(This is partly LISP, partly script.)

 

I have a script file to print lots of drawings. This works well but I always set SDI=1 before we start as I don't like 500+ files open at one time. No problem there, I usually work in SDI mode anyway. However I have tweaked the script generator as a co-worker would like SDI reset at the end. No problem, add the following lines to the start and end of the script.

 

(setq SDIMode (getvar "SDI"))
....
(setvar "SDI" SDIMode)

 

Logically, your Script must be written to account for SDI=1 inherently when you exclude the CLOSE call... When in SDI=1, one can simply call OPEN after saving the active Document, whereas in SDI=0 one must first CLOSE the active Document (unless one wants myriad Drawings to remain opened in the same session).

 

That said, without having seen your Script, I'd venture a guess that it is dependent on SDI=1... Rather than attempting to employ LISP to restore the originating value across Document Namespaces, prior to forcing SDI=1 (a Global Variable only exists within that Document's Namespace), you might consider instead writing the original value to User's Registry.

 

;; start script
(setenv "OldSdiMode" (itoa (getvar 'sdi)))
(setvar 'sdi 1)

;; Do some stuff

;; end script
(setvar 'sdi (atoi (getenv "OldSdiMode")))

 

... Besides, one day (soon?) you'll employ your vast, yet growing knowledge of The Dark Side (aka .NET Development), and will no longer need to worry of such petty matters, through the proper use of static Property Objects, Fields, side Databases, and Core Console... Mwaaaatttttahhhhahahhahahhhahahahaha!

 

/EvilLaugh

Edited by BlackBox
Posted

for now the script is running fine using MSasu' (VL-BB bits so I'm not changing it again but I did wonder how to write to the registry with LISP so thanks for that.

 

The script is dependant on running in SDI mode (as BB correctly says). I open the next drawing without having to close the previous one. I draw a line to ensure ALL files have changed and then discard changes. Most of us here chose to work in SDI due to an unreliable net work all those years ago (only lose 1 drawing not lots when it crashed) so it was sensible to run the script in SDI mode. I did once convert the code to VBA but couldn't get it to work in SDI (sound familiar BB?) and not sure how the machines would cope with 500 drawings open at a time. It was far easier to run a script in SDI but yes, a VB.Net solution is on the list.

 

As for the name of the variable affecting the script, I know it shouldn't but it did. Like the other example I cited, the name of a file shouldn't affect the print's orientation but it did. Just one of those things that we come to love AutoCAD for.

Posted
...not sure how the machines would cope with 500 drawings open at a time.

 

There would not be 500 drawings open at a time - the Script would open, modify, save & close each drawing processed, meaning there would only ever be two drawings open (the drawing being processed and the drawing from which the Script is run).

Posted
even in MDI mode?

 

Yes, the Script can open, modify, save and close each drawing in MDI mode before processing the next drawing.

Posted

do you mean CAN or WILL? I couldn't get the "close" to work when I tried. In SDI it was easy.

Posted
do you mean CAN or WILL?

 

Both if you have the Script set up correctly ;)

 

Try the following for each line of the Script in MDI mode:

_.open [color=red]<your-filename-here>[/color] [color=red]<perform-operations-here>[/color] _.qsave _.close

This is the method I also use in my Batch Attribute Editor program.

 

PS: Note that there is no space after 'close' since the operations for the next drawing would appear on a new line in the Script (a new line represents 'Enter' in a Script, as I'm sure you know).

Posted

Thanks, I will file that but may never use it. :oops:

 

When I first wrote this script (we were using R14 and Cad Tutor didn't exist) I found that if I closed the current file the script would stop. I could open one file, , open next file and then close the previous file but I think even that halted the script. It was far easier to run in SDI.

 

Even that had problems though. We didn't want to save the file but my script kept saving! AutoDesk had different statements to the "Do you want to save?" question depending if you were running a script (discard changes?) to typing -plot at the keyboard (save changes?).

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