Results 1 to 8 of 8

Thread: Add Plot Style value to layer

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Red face Add Plot Style value to layer

    Hi All-

    I just modified a routine I have that allows me to export all of the layers in a drawing with and their values (i.e., color, linetype, lineweight, plot style name, plot and description) to an external text file. I have another routine that I modified that will read the layer text file and recreate all of the layers. After some fussing, I have been able to get most of it to work except for the Plot Style name value. I am using the following code to add the value to a layer that already exists in the drawing.

    (vl-load-com)
    (setq lyrnam "A-wall" lyrpltstyl "BLACK")
    (setq lyrobj (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) lyrnam))
    (vla-put-plotstylename lyrobj lyrpltstyl)

    For some reason the above code will not work. Any help is greatly appreciated. Thank you.

    Manuel A. Ayala

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    Have you added the Plot Style to the available Plot Styles? You can look at the "ACAD_PLOTSTYLENAME" dictionary for the list of available styles.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    Opie-

    I did a dictionary search on "ACAD_PLOTNAMESTYLE" as follows:

    (setq psn-lst (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME")) and I found that the plot style name I was trying to assign did not exist. I have two questions: 1) how can I first test to see if the plot style name exists in the dictionary and 2) how do I go about adding it to the dictionary? Thanks.

    Manuel

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    I don't know. I haven't successfully added a new plot style to a drawing through code.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    Opie-

    Do you know how I can at least build a list of those plot styles stored in the ACAD_PLOTSTYLENAME dictionary? Also, do you know if there is a way to determine via code whether a drawing is setup for style (stb) or color dependent (ctb) plot styles? Thanks.

    Manuel

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    You can use my code in this thread to show you how to work with dictionaries.

    Typically you entget the dictionary entities, e.g:
    Code:
    (setq root (entget (namedobjdict)))
    (setq ed (entget (cdr (cadr (member '(3 . "ACAD_PLOTSTYLENAME") root)))))
    Then stepping through ed each code 3 contains the name of the style, then it's followed by code 350 which contains the ename of the actual style entity.

    Or else you use dictnext. But then you first need to find the ACAD_PLOTSTYLENAME ename. (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME") gives you an entget-like list, of which the -1 code is the ename. Then you use that ename with dictnext (works similar to tblnext).

    However, the problem with dictnext is you don't get the dictionary item's name returned ... only its data. E.g.
    Code:
    (setq dict (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME"))
    (dictnext (cdr (assoc -1 dict)) t)
    Returns he following
    Code:
    ((-1 . <Entity name: 7efa9c50>) (0 . "ACDBPLACEHOLDER") (5 . "A") (102 . 
    "{ACAD_REACTORS") (330 . <Entity name: 7efa9c58>) (102 . "}") (330 . <Entity 
    name: 7efa9c58>))
    Nowhere does it tell you that this is the "Normal" style. Only way of getting that is to look through the dict datalist in above code.

  7. #7
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Smile Re: Add Plot Style value to layer

    irneb-

    You code and suggestions worked great. Thank you for your assistance, I greatly appreciate it.

    Manuel

  8. #8
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Add Plot Style value to layer

    Pleasure, glad I could help!

Similar Threads

  1. Specify the Plot Style for certain entities in a Named plot style drawing
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2014-10-28, 11:52 AM
  2. Set Plot Style-Assign Style to Layer
    By jeff.richards in forum AutoCAD General
    Replies: 3
    Last Post: 2010-02-02, 05:54 PM
  3. Set a layer's plot style and description
    By brendan.j.mallon in forum Dot Net API
    Replies: 2
    Last Post: 2009-11-03, 12:32 AM
  4. Replies: 0
    Last Post: 2006-06-07, 05:15 PM
  5. Plot Style Field in Layer Dialog
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-02-21, 05:17 PM

Posting Permissions

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