.NET

Reply
Valued Contributor
Posts: 81
Registered: ‎03-06-2012
Message 1 of 13 (416 Views)
Accepted Solution

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

416 Views, 12 Replies
03-09-2012 07:57 PM

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.



*Expert Elite*
Jeff_M
Posts: 3,956
Registered: ‎07-22-2003
Message 2 of 13 (378 Views)

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

03-09-2012 10:00 PM in reply to: chockalingam

Those are controlled by the drawing's Current sysvars.

CECOLOR

CELTYPE

CELWEIGHT

Jeff_M, also a frequent Swamper
Valued Contributor
Posts: 81
Registered: ‎03-06-2012
Message 3 of 13 (374 Views)

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

03-09-2012 10:06 PM in reply to: chockalingam

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

Valued Mentor
KerryBrown
Posts: 259
Registered: ‎11-29-2008
Message 4 of 13 (366 Views)

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

03-09-2012 10:14 PM 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

 

//-------------------------------------------------------

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

Valued Contributor
Posts: 81
Registered: ‎03-06-2012
Message 5 of 13 (363 Views)

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

03-09-2012 10:28 PM 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

 


 

 

Valued Mentor
KerryBrown
Posts: 259
Registered: ‎11-29-2008
Message 6 of 13 (352 Views)

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

03-09-2012 10:55 PM in reply to: chockalingam

 

Works for me. ... see attached piccy.

 

Before and After.PNG

//-------------------------------------------------------

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

Valued Contributor
Posts: 81
Registered: ‎03-06-2012
Message 7 of 13 (347 Views)

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

03-09-2012 11:01 PM 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

Valued Contributor
Posts: 81
Registered: ‎03-06-2012
Message 8 of 13 (341 Views)

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

03-09-2012 11:15 PM in reply to: chockalingam

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

Valued Mentor
KerryBrown
Posts: 259
Registered: ‎11-29-2008
Message 9 of 13 (335 Views)

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

03-09-2012 11:35 PM 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.

//-------------------------------------------------------

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

*Expert Elite*
Alfred.NESWADBA
Posts: 8,482
Registered: ‎06-29-2007
Message 10 of 13 (331 Views)

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

03-09-2012 11:47 PM in reply to: chockalingam

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community