.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing system variables

9 REPLIES 9
Reply
Message 1 of 10
SRSDS
1396 Views, 9 Replies

Changing system variables

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?

9 REPLIES 9
Message 2 of 10
michael.robertson
in reply to: SRSDS

You could try to set the variable programmitically instead of sending commands using:

 

Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable(variable, value)

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
Message 3 of 10
SRSDS
in reply to: michael.robertson

Exactly what I'm after. 

I got an error saying SetSystemVariable is not a member of Autodesk.AutoCAD.ApplicationServices.Application.

But google it and found  Application.SetSystemVariable("MAXSORT", 100)

Thankyou!

Message 4 of 10
SRSDS
in reply to: SRSDS

Hi again.

Is there a similar way to change the document variable settings?

I also want to change things like the drawing annotation scale

 

 

Message 5 of 10
pjfontes
in reply to: SRSDS

 


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

Message 6 of 10
jeff
in reply to: pjfontes

Some you can set through the Database object like Database.Cannoscale if that is what you are talkink about

You can also find your answers @ TheSwamp
Message 7 of 10
pjfontes
in reply to: jeff

Great!  I knew I was over-thinking it..

 

Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

 

Dim acCurDb As Database = acDoc.Database

acCurDb.Attmode = MyValue

 

 

Message 8 of 10
GTVic
in reply to: pjfontes

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.

Message 9 of 10
jeff
in reply to: GTVic

Why not use Database.Cannoscale?

You can also find your answers @ TheSwamp
Message 10 of 10
GTVic
in reply to: jeff


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

 

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost