Results 1 to 3 of 3

Thread: NewColorInfo as color throws read-only

  1. #1
    Member
    Join Date
    2009-10
    Posts
    6
    Login to Give a bone
    0

    Default NewColorInfo as color throws read-only

    Hi,

    From the RevitSDK2014 I copy/pasted the code as stated below, but when I execute the code it keeps throwing an exception. My problem is that the newcolor is created but as read-only and so I am not allowed to change its settings. Anyone any ideas how to resolve this read-only issue?

    regards,
    Raymond



    Private Function NewColorInfo(ByVal appCreation As Autodesk.Revit.Creation.Application) As Color
    ' Create a new color
    Dim color As Autodesk.Revit.DB.Color = appCreation.NewColor()

    ' Set its RGB values
    color.Red = CByte(127)
    color.Green = CByte(64)
    color.Blue = CByte(32)

    ' Display the color info
    Dim info As New StringBuilder()
    info.AppendLine("Red:" & vbTab & color.Red.ToString())
    info.AppendLine("Green:" & vbTab & color.Green.ToString())
    info.AppendLine("Blue:" & vbTab & color.Blue.ToString())

    TaskDialog.Show("Revit", info.ToString())

    Return color
    End Function

  2. #2
    Member
    Join Date
    2009-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: NewColorInfo as color throws read-only

    After a bit of more testing I have found out that 'appCreation' is editable (isReadOnly = false) but 'color' = appCreation.NewColor is read-only.

  3. #3
    Member
    Join Date
    2012-09
    Posts
    34
    Login to Give a bone
    0

    Default Re: NewColorInfo as color throws read-only

    Looks like the API docs are inconsistent/wrong on the Color class.

    Looking at the property Blue (or Red or Green), the following sentence is located at the top of the page:

    Get the blue channel of the color. Setting a channel is obsolete in Autodesk Revit 2013. Please create a new color instead.

    I also see that there is a constructor for Color, which allows you to pass the Red, Green & Blue values as arguments.

    So, disregard the sample and the appCreation.NewColor() method, and do something like this:

    Dim color As New Autodesk.Revit.DB.Color(CByte(127), CByte(64), CByte(32))

Similar Threads

  1. Replies: 0
    Last Post: 2014-05-28, 01:06 PM
  2. Open Read-Only: The ability to open a worksharing enabled file in a read only mode.
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 5
    Last Post: 2012-09-05, 07:02 PM
  3. Replies: 0
    Last Post: 2011-11-30, 05:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •