.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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:
Command:
AutoCAD menu utilities loaded.ANNOAUTOSCALE 4
CANNOSCALE 1:100
Command: _RIBBON
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?
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You could try to set the variable programmitically instead of sending commands using:
Autodesk.AutoCAD.ApplicationServices.Application.S
FL. Dept. of Transportation
CADD Applications Developer
HPxw4600 Workstation
Core 2 Duo 2.33ghz, 8gb RAM
nVidia Quadro FX1700
Win7 64bit
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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)
Thankyou!
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi again.
Is there a similar way to change the document variable settings?
I also want to change things like the drawing annotation scale
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
SRSDS wrote:Hi again.
Is there a similar way to change the document variable settings?
I also want to change things like the drawing annotation scale
Excellent Question!
Anybody? Does the document have to be opened and active?
Thanks.
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Some you can set through the Database object like Database.Cannoscale if that is what you are talkink about
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Great! I knew I was over-thinking it..
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
acCurDb.Attmode = MyValue
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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 TryIf 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.
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Why not use Database.Cannoscale?
Re: Changing system variables
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
jeff wrote: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.
DocumentManager.MdiActiveDocument.Editor.Document.
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.

