Change an Entities color.

Discussion in 'AutoCAD' started by David M. Gardner, Sep 23, 2004.

  1. I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    David M. Gardner, Sep 23, 2004
    #1
  2. David M. Gardner

    Ed Jobe Guest

    An AcadEntity does have a Color property, but (hint) what kind of object might you find in the Linetypes collection? Its faster to use a filtered selection set as Bob Coward showed you already. First find all the objects that have hidden linetypes. Then change their color. If you want to iterate through every object in the dwg, you can use:
    For Each tEnt In ThisDrawing.Modelspace
    If tEnt.Linetype = "HIDDEN" Then
    tEnt.Color = acMagenta
    End If
    Next tEnt

    Then repeat the process for Paperspace.

    --
    ----
    Ed
    ----
    I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    Ed Jobe, Sep 23, 2004
    #2
  3. David M. Gardner

    Ed Jobe Guest

    BTW, its not good cad practice to change a color to other than ByLayer. You may want to create a magenta layer and change the ents Layer property instead of the Color Property. While were on the subject, the same holds true for linetypes. The previous post will only get you ents if they have had the Linetype property changed from ByLayer to "HIDDEN" (also not a good practice). To find an ent that appears magenta, you will have to also look for ents whose Layer prop is the name of a layer with a magenta Color prop.

    --
    ----
    Ed
    ----
    An AcadEntity does have a Color property, but (hint) what kind of object might you find in the Linetypes collection? Its faster to use a filtered selection set as Bob Coward showed you already. First find all the objects that have hidden linetypes. Then change their color. If you want to iterate through every object in the dwg, you can use:
    For Each tEnt In ThisDrawing.Modelspace
    If tEnt.Linetype = "HIDDEN" Then
    tEnt.Color = acMagenta
    End If
    Next tEnt

    Then repeat the process for Paperspace.

    --
    ----
    Ed
    ----
    I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    Ed Jobe, Sep 23, 2004
    #3
  4. I agree with you on the bylayer thing. Question: What do you do when having parts that have both visable and hidden lines? ie. a screw. You would have a layer for the screw and a layer for the 2 hidden lines that make the thread. Sorry I know off subject just a question.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
    BTW, its not good cad practice to change a color to other than ByLayer. You may want to create a magenta layer and change the ents Layer property instead of the Color Property. While were on the subject, the same holds true for linetypes. The previous post will only get you ents if they have had the Linetype property changed from ByLayer to "HIDDEN" (also not a good practice). To find an ent that appears magenta, you will have to also look for ents whose Layer prop is the name of a layer with a magenta Color prop.

    --
    ----
    Ed
    ----
    An AcadEntity does have a Color property, but (hint) what kind of object might you find in the Linetypes collection? Its faster to use a filtered selection set as Bob Coward showed you already. First find all the objects that have hidden linetypes. Then change their color. If you want to iterate through every object in the dwg, you can use:
    For Each tEnt In ThisDrawing.Modelspace
    If tEnt.Linetype = "HIDDEN" Then
    tEnt.Color = acMagenta
    End If
    Next tEnt

    Then repeat the process for Paperspace.

    --
    ----
    Ed
    ----
    I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    David M. Gardner, Sep 23, 2004
    #4
  5. My problem here is that I have more than just lines that have the linetype of hidden. How do I do that?

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
    An AcadEntity does have a Color property, but (hint) what kind of object might you find in the Linetypes collection? Its faster to use a filtered selection set as Bob Coward showed you already. First find all the objects that have hidden linetypes. Then change their color. If you want to iterate through every object in the dwg, you can use:
    For Each tEnt In ThisDrawing.Modelspace
    If tEnt.Linetype = "HIDDEN" Then
    tEnt.Color = acMagenta
    End If
    Next tEnt

    Then repeat the process for Paperspace.

    --
    ----
    Ed
    ----
    I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    David M. Gardner, Sep 23, 2004
    #5
  6. David M. Gardner

    Ed Jobe Guest

    Adjust the sample Bob gave you. He showed you how to filter on two criteria. Reduce it to one. Redim the array to one element (use 0 instead of 1 since the array is zero-based) and then set the critera for the element (remove his line for index 0 and change the 1 to a zero in the "hidden" line).

    --
    ----
    Ed
    ----
    My problem here is that I have more than just lines that have the linetype of hidden. How do I do that?

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
    An AcadEntity does have a Color property, but (hint) what kind of object might you find in the Linetypes collection? Its faster to use a filtered selection set as Bob Coward showed you already. First find all the objects that have hidden linetypes. Then change their color. If you want to iterate through every object in the dwg, you can use:
    For Each tEnt In ThisDrawing.Modelspace
    If tEnt.Linetype = "HIDDEN" Then
    tEnt.Color = acMagenta
    End If
    Next tEnt

    Then repeat the process for Paperspace.

    --
    ----
    Ed
    ----
    I want to filter only entities that have a linetype of hidden and change their color to magenta. But this does not work:

    Dim tEnt As AcadEntity
    For Each tEnt In ThisDrawing.Linetypes("HIDDEN")
    tEnt.color = acMagenta
    Next

    I get "Object doesn't support this property or method.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    Ed Jobe, Sep 23, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.