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

Change Color, Line Type and Line weight without selecting any objects

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
chockalingam
1229 Views, 12 Replies

Change Color, Line Type and Line weight without selecting any objects

Hi,

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.

12 REPLIES 12
Message 2 of 13
Jeff_M
in reply to: chockalingam

Those are controlled by the drawing's Current sysvars.

CECOLOR

CELTYPE

CELWEIGHT

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 13
chockalingam
in reply to: chockalingam

Can you guide me, to use this in .net code

Message 4 of 13
kdub_nz
in reply to: chockalingam

 

Untested

 

using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

// AcadApp.SetSystemVariable(string name, object value)

	AcadApp.SetSystemVariable("CECOLOR", "BYLAYER")
	AcadApp.SetSystemVariable("CELTYPE", "ByLayer")
	AcadApp.SetSystemVariable("CELWEIGHT", -1)

 Regards

 

//

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 5 of 13
chockalingam
in reply to: chockalingam

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

 


 

 

Message 6 of 13
kdub_nz
in reply to: chockalingam

 

Works for me. ... see attached piccy.

 

Before and After.PNG

//

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 7 of 13
chockalingam
in reply to: chockalingam

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.DocumentManager.MdiActiveDocument.LockDocument
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

End If
acTrans.Commit()
End Using
End Using

Message 8 of 13
chockalingam
in reply to: chockalingam

But the Only Issue in above code is we can't reback to "ByLayer"

Message 9 of 13
kdub_nz
in reply to: chockalingam

 

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.

//

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 10 of 13

Hi,

 

>> we can't reback to "ByLayer"

Why not, this code does not Work?

acDoc.Database.Celtype = "byLayer"

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 11 of 13
kdub_nz
in reply to: Alfred.NESWADBA

 

Alfred,

db.Celtype is an ObjectId

 

 

But this works for me too.

 

	
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcadColor = Autodesk.AutoCAD.Colors;


            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            db.Celweight = LineWeight.LineWeight015;
            db.Cecolor   = AcadColor.Color.FromColorIndex(ColorMethod.ByAci, 1);
            db.Celtype   = db.ContinuousLinetype;
            
            AcadApp.ShowAlertDialog("NOW WE'LL CHANGE THEM BACK.");

            db.Celweight = LineWeight.ByLayer;
            db.Cecolor   =  AcadColor.Color.FromColorIndex(ColorMethod.ByAci,256);
            db.Celtype   = db.ByLayerLinetype;
			
	

 

 

 Regards,

 

 

//

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 12 of 13
chockalingam
in reply to: chockalingam

Yes now i got the solution, This works for me.......

Message 13 of 13
Alfred.NESWADBA
in reply to: kdub_nz

Hi,

 

>> Alfred, db.Celtype is an ObjectId

Ooops .... thank you (looked at the wrong place).

 

Nice weekend, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

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