I am trying to Change the Color, Line Type and Line weight in Properties Pallete without selecting any objects, but i don't know how to do this.
Solved! Go to Solution.
Those are controlled by the drawing's Current sysvars.
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; // AcadApp.SetSystemVariable(string name, object value) AcadApp.SetSystemVariable("CECOLOR", "BYLAYER") AcadApp.SetSystemVariable("CELTYPE", "ByLayer") AcadApp.SetSystemVariable("CELWEIGHT", -1)
On using the above code,
AcadApp.SetSystemVariable("CECOLOR", "BYLAYER")- Results No Change
AcadApp.SetSystemVariable("CELTYPE", "ByLayer")- Results in "eInvalidInput" error
AcadApp.SetSystemVariable("CELWEIGHT", -1)- Results in "eInvalidInput" error
Works for me. ... see attached piccy.
I don't know why it is not working for me.....
But i got the solution in another way, my solution code follows,
Using lock As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.D
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Using acTrans As Transaction = acDoc.Database.TransactionManager.StartTransaction
acDoc.Database.Celweight = LineWeight.LineWeight015
acDoc.Database.Cecolor = Autodesk.AutoCAD.Colors.Color.FromColor(Color.Red)
Dim acLineTypTbl As LinetypeTable
acLineTypTbl = acTrans.GetObject(acDoc.Database.LinetypeTableId, OpenMode.ForRead)
Dim sLineTypName As String = "Continuous"
If acLineTypTbl.Has(sLineTypName) = True Then
'' Set the linetype Center current
acDoc.Database.Celtype = acLineTypTbl(sLineTypName)
'' Save the changes
Please clarify your last post. ??
And the code you posted is different to your initial question ... but I see how I could confuse your intent.
>> we can't reback to "ByLayer"
Why not, this code does not Work?
acDoc.Database.Celtype = "byLayer"
- alfred -
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.