I want a few sendcommands executed when AutoCAD starts up.
Dim doc As Document = Application.DocumentManager.MdiActiveDocument doc.SendStringToExecute("ANNOAUTOSCALE 4" & vbCr, False, False, True)
The DocumentCreated or DocumentActivated events doen't seem to trigger on start up so i've added them to the initialize sub. (Maybe the dll isn't loaded at this point)
And in the initialize sub then they are ignored.Commandline looks like this:
AutoCAD menu utilities loaded.ANNOAUTOSCALE 4
If I put them in a routine they are slow and get minced in with other commands. Can anyone suggest a good place. Ir is SendStringToExecute not the right method?
You could try to set the variable programmitically instead of sending commands using:
Exactly what I'm after.
I got an error saying SetSystemVariable is not a member of Autodesk.AutoCAD.ApplicationServices.Applicatio
But google it and found Application.SetSystemVariable("MAXSORT", 100)
Is there a similar way to change the document variable settings?
I also want to change things like the drawing annotation scale
Anybody? Does the document have to be opened and active?
Great! I knew I was over-thinking it..
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
acCurDb.Attmode = MyValue
You can use the following:
Imports Autodesk.AutoCAD.ApplicationServices Try Dim lms As Object = Application.GetSystemVariable("CANNOSCALE") Application.SetSystemVariable("CANNOSCALE", lms) Catch ex As Autodesk.AutoCAD.Runtime.Exception End Try
If a drawing is not open for a drawing based variable you will get an eInvalidInput exception. So you can mask that with the error trapping plus the error trapping helps if the version of AutoCAD does not support the variable you are using.
Why not use Database.Cannoscale?
I understood that CANNOSCALE was just an example of the type of variable he would like to set so my suggestion is a generic solution.
On a side topic, I noticed that other 3rd party apps can have the problem of interrupting the startup sequence when using SendStringToExecute. When I had AutoCAD 2009 infected with the Adobe plug-in I would get an Adobe initialization message on the commandline followed by "Unknown command: OMMANDLINE" (missing the 'C') because AutoCAD was probably doing it's own SendStringToExecute of "COMMANDLINE" that was being interrupted by the Adobe plug-in. IMO, Autodesk shouldn't be programming its products this way but if you have to use SendStringToExecute I think there is a function you can call to make sure other commands are not being executed.
Or perhaps a document lock would work but I wonder if that could crash another plug-in that was trying to initialize. Assuming the other plug-in was not written properly.