• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012
    Accepted Solution

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

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

    

    Please use plain text.
    *Expert Elite*
    Posts: 3,046
    Registered: ‎07-22-2003

    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
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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

    Please use plain text.
    Valued Mentor
    KerryBrown
    Posts: 259
    Registered: ‎11-29-2008

    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


    I do not endorse the social media app links below:smileyembarrassed:

    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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

     


     

     

    Please use plain text.
    Valued Mentor
    KerryBrown
    Posts: 259
    Registered: ‎11-29-2008

    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


    I do not endorse the social media app links below:smileyembarrassed:

    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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

    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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"

    Please use plain text.
    Valued Mentor
    KerryBrown
    Posts: 259
    Registered: ‎11-29-2008

    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


    I do not endorse the social media app links below:smileyembarrassed:

    Please use plain text.
    *Expert Elite*
    Posts: 6,452
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.