Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: update layer color in documents collection

  1. #1
    Joe Burke Guest

    update layer color in documents collection

    All,

    Using 2004. The following is driving me slightly crazy.

    Assuming I have two files open and both have objects on layer zero color bylayer.
    Layer zero is just an example.

    This "test" function changes the color of layer zero in all files contained in the
    documents collection.

    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)
    )
    )

    OK so far. The color of layer zero is changed in all open files. But I only see the
    layer color update in the active file. Switching to the other open file does not
    reflect the updated layer zero color. Regen or regenall does not update the color of
    objects on layer zero in the other open file. Though the layer color is in fact
    changed.

    What does update objects on layer zero (in the other open file) is simply picking the
    layer toolbar dropdown menu or opening Layer Manager without any changes.

    Any thoughts regarding what's going on here would be welcome.

    Thanks
    Joe Burke

  2. #2
    Jason Piercey Guest
    Hi Joe,

    Dives me crazy also, and it is not just layer zero.
    Noticed this the other day when penning a quick
    and dirty function to match up some layer colors
    from an open file. Using 2005 here.


    --
    Autodesk Discussion Group Facilitator



    "Joe Burke" <joburke@hawaii.rr.com> wrote in message
    news:4252a7b5_3@newsprd01...
    All,

    Using 2004. The following is driving me slightly crazy.

    Assuming I have two files open and both have objects on layer zero color
    bylayer.
    Layer zero is just an example.

    This "test" function changes the color of layer zero in all files
    contained in the
    documents collection.

    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)
    )
    )

    OK so far. The color of layer zero is changed in all open files. But I
    only see the
    layer color update in the active file. Switching to the other open file
    does not
    reflect the updated layer zero color. Regen or regenall does not update
    the color of
    objects on layer zero in the other open file. Though the layer color is in
    fact
    changed.

    What does update objects on layer zero (in the other open file) is simply
    picking the
    layer toolbar dropdown menu or opening Layer Manager without any changes.

    Any thoughts regarding what's going on here would be welcome.

    Thanks
    Joe Burke

  3. #3
    Joe Burke Guest
    Hi Jason,

    It's nice to know I'm not alone in this quandary. :-)

    I only used layer zero as an example so the demo code would work given any set of
    files. Agreed, the issue isn't limited to layer zero.

    Regards
    Joe

    Hi Joe,

    Dives me crazy also, and it is not just layer zero.
    Noticed this the other day when penning a quick
    and dirty function to match up some layer colors
    from an open file. Using 2005 here.


    --
    Autodesk Discussion Group Facilitator

  4. #4
    Luis Esquivel Guest
    Joe and Jason,

    See if that works.


    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)

    (vla-save x)

    )
    )


    LE.

  5. #5
    Jason Piercey Guest
    Hi Luis,

    I'll have to test that out later, work is getting in the
    way of everything right now.

    --
    Autodesk Discussion Group Facilitator



    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252b36c$1_3@newsprd01...
    Joe and Jason,

    See if that works.


    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)

    (vla-save x)

    )
    )


    LE.

  6. #6
    Joe Burke Guest
    Hi Luis,

    Adding (vla-save x) doesn't seem to make a difference.

    And of course I wouldn't want to be forced to such a solution, since I go out of my
    way to not to save open documents when dealing with a mix of ODBX documents and docs
    in the documents collection. An issue I didn't mention previously, though in play
    given the bigger picture.

    Regards
    Joe Burke


    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252b36c$1_3@newsprd01...
    Joe and Jason,

    See if that works.


    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)

    (vla-save x)

    )
    )


    LE.

  7. #7
    Luis Esquivel Guest
    I'll have to test that out later, work is getting in the
    way of everything right now.
    Okay, if you guys need help or have a Janitor position, let me know..... :-)

    LE.

  8. #8
    Luis Esquivel Guest
    Is working here Joe at least on all the tests I did on acad 2005...


    And of course I wouldn't want to be forced to such a solution, since I go
    out of my
    way to not to save open documents when dealing with a mix of ODBX
    documents and docs
    in the documents collection. An issue I didn't mention previously, though
    in play
    given the bigger picture.

  9. #9
    Luis Esquivel Guest
    Sorry Joe,

    I closed and re open autocad, and now what I was doing does not work.....
    very strange....


    LE.

    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252bf04$1_3@newsprd01...
    Is working here Joe at least on all the tests I did on acad 2005...


    And of course I wouldn't want to be forced to such a solution, since I
    go
    out of my
    way to not to save open documents when dealing with a mix of ODBX
    documents and docs
    in the documents collection. An issue I didn't mention previously,
    though
    in play
    given the bigger picture.

  10. #10
    Luis Esquivel Guest
    ok.... I did the test with two drawings again....

    1. I open two dwgs
    2 I did the color change with your code on the active dwg
    3. I open the other drawing and the color is not updated
    4. went I go to the other drawing and manually click on the qsave, the color
    is updated
    5. if I go back to the previous dwg and call your routine and change the
    color, now both dwgs are updated.

    hope that makes some sense... even if not works for you....

    LE.

    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252c200$1_2@newsprd01...
    Sorry Joe,

    I closed and re open autocad, and now what I was doing does not work.....
    very strange....


    LE.

    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252bf04$1_3@newsprd01...
    Is working here Joe at least on all the tests I did on acad 2005...


    And of course I wouldn't want to be forced to such a solution, since I
    go
    out of my
    way to not to save open documents when dealing with a mix of ODBX
    documents and docs
    in the documents collection. An issue I didn't mention previously,
    though
    in play
    given the bigger picture.



  11. #11
    Joe Burke Guest
    Hi Luis,

    Thanks for trying. I understand what you mean, but it doesn't work that way under
    2004.

    I also tried releasing the "layers" object inside the vlax-for function. No help.

    Strange....

    Joe Burke

    ok.... I did the test with two drawings again....

    1. I open two dwgs
    2 I did the color change with your code on the active dwg
    3. I open the other drawing and the color is not updated
    4. went I go to the other drawing and manually click on the qsave, the color
    is updated
    5. if I go back to the previous dwg and call your routine and change the
    color, now both dwgs are updated.

    hope that makes some sense... even if not works for you....

    LE.

    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252c200$1_2@newsprd01...
    Sorry Joe,

    I closed and re open autocad, and now what I was doing does not work.....
    very strange....


    LE.

    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:4252bf04$1_3@newsprd01...
    Is working here Joe at least on all the tests I did on acad 2005...


    And of course I wouldn't want to be forced to such a solution, since I
    go
    out of my
    way to not to save open documents when dealing with a mix of ODBX
    documents and docs
    in the documents collection. An issue I didn't mention previously,
    though
    in play
    given the bigger picture.





  12. #12
    James Allen Guest
    Hi Joe, just taking a shot here that I haven't noticed mention of yet.

    Perhaps adding (vla-Update AcadObject) would help? Luis recently introduced
    me to this and it has been helpful, though I am still at a loss how to know
    when it needs to be used.

    Also, does it make any difference to use the TrueColor property rather than
    Color? I expect not, but perhaps worth a try. Regardless, I remember
    someone mentioning that the Color prop will cease to be supported.

    --
    James Allen, EIT
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO


    "Joe Burke" <joburke@hawaii.rr.com> wrote in message
    news:4252a7b5_3@newsprd01...
    All,

    Using 2004. The following is driving me slightly crazy.

    Assuming I have two files open and both have objects on layer zero color
    bylayer.
    Layer zero is just an example.

    This "test" function changes the color of layer zero in all files
    contained in the
    documents collection.

    (defun c:test ( / documents clrnum layers )
    (setq documents (vla-get-documents (vlax-get-acad-object)))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)
    )
    )

    OK so far. The color of layer zero is changed in all open files. But I
    only see the
    layer color update in the active file. Switching to the other open file
    does not
    reflect the updated layer zero color. Regen or regenall does not update
    the color of
    objects on layer zero in the other open file. Though the layer color is in
    fact
    changed.

    What does update objects on layer zero (in the other open file) is simply
    picking the
    layer toolbar dropdown menu or opening Layer Manager without any changes.

    Any thoughts regarding what's going on here would be welcome.

    Thanks
    Joe Burke

  13. #13
    Joe Burke Guest
    Hi James,

    That's an interesting idea. Unfortunately it doesn't seem to solve the problem.

    Here's a revised "test" function which incorporates the idea as I understand it.

    (defun c:test ( / *acad* documents clrnum layers )
    (setq *acad* (vlax-get-acad-object))
    (setq documents (vla-get-documents *acad*))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)
    ;(vlax-release-object layers) ;doesn't help
    ;(vla-update *acad*) ;here
    )
    (vla-update *acad*) ;or here
    (princ)
    )

    Regardless, I'm curious about the application of (vla-update AcadObject). When,
    where, and to what purpose? I must have missed Luis speaking on this topic.

    I'll try using TrueColor, but I also expect not. Right, the Color property will be
    phased out. I wonder, is it still supported under 2006?

    Regards,
    Joe Burke

    Hi Joe, just taking a shot here that I haven't noticed mention of yet.

    Perhaps adding (vla-Update AcadObject) would help? Luis recently introduced
    me to this and it has been helpful, though I am still at a loss how to know
    when it needs to be used.

    Also, does it make any difference to use the TrueColor property rather than
    Color? I expect not, but perhaps worth a try. Regardless, I remember
    someone mentioning that the Color prop will cease to be supported.

    --
    James Allen, EIT
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO

  14. #14
    James Allen Guest
    vla-Update:

    Here's the context:
    http://discussion.autodesk.com/threa...sageID=4226890

    In that particular case, it seemed to help the problem but in the end didn't
    entirely resolve it.

    Color:

    When I get into 2k6 I'll let you know, if someone else doesn't first.

    James


    "Joe Burke" <joburke@hawaii.rr.com> wrote in message
    news:4253f462$1_3@newsprd01...
    Hi James,

    That's an interesting idea. Unfortunately it doesn't seem to solve the
    problem.

    Here's a revised "test" function which incorporates the idea as I
    understand it.

    (defun c:test ( / *acad* documents clrnum layers )
    (setq *acad* (vlax-get-acad-object))
    (setq documents (vla-get-documents *acad*))
    (initget 7)
    (setq clrnum (getint "\nEnter layer zero color number: "))
    (vlax-for x documents
    (setq layers (vla-get-layers x))
    (vlax-put (vla-item layers "0") 'Color clrnum)
    ;(vlax-release-object layers) ;doesn't help
    ;(vla-update *acad*) ;here
    )
    (vla-update *acad*) ;or here
    (princ)
    )

    Regardless, I'm curious about the application of (vla-update AcadObject).
    When,
    where, and to what purpose? I must have missed Luis speaking on this
    topic.

    I'll try using TrueColor, but I also expect not. Right, the Color property
    will be
    phased out. I wonder, is it still supported under 2006?

    Regards,
    Joe Burke

  15. #15
    Joe Burke Guest
    James,

    Oh, that thread... another flying saucer. :-)

    Joe

    vla-Update:

    Here's the context:
    http://discussion.autodesk.com/threa...sageID=4226890

    In that particular case, it seemed to help the problem but in the end didn't
    entirely resolve it.

    Color:

    When I get into 2k6 I'll let you know, if someone else doesn't first.

    James

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 05-11-2010, 10:28 AM
  2. same layer with a differenrt color in layouts?
    By frederic pichon in forum AutoCAD
    Replies: 8
    Last Post: 01-30-2005, 10:06 PM
  3. Color 2 Layer
    By GaryDF in forum Customization
    Replies: 15
    Last Post: 12-24-2004, 12:19 PM
  4. SSM & Layer Color
    By Terry Scanlon in forum Printing
    Replies: 2
    Last Post: 12-17-2004, 01:29 PM
  5. copy layer (bycolor to color)
    By Willie Wilbers in forum AutoCAD
    Replies: 1
    Last Post: 10-01-2004, 07:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum