Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Assign Lineweight per color not layer

  1. #1
    Member
    Join Date
    2008-05
    Posts
    10
    Login to Give a bone
    0

    Default Assign Lineweight per color not layer

    Does anyone have a program that will assign a line weight per each individual color not layer. I need to assign line weights to these colors in a bunch of drawings.

    1 - .016
    2 - .007
    3 - .014
    4 - .024
    5 - .002
    6 - .031
    7 - .006
    8 - .002

    The reason why they need to be assigned is for them to by imported into Revit Structure and for them to show up correctly in revit.

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    See if this does what you want. The numbers I have for lineweights are different than the ones you list, so I couldn't test it, but it should work.

    Code:
    (vl-load-com)
    (defun LineweightByColor (Doc LwClrList / )
        
        (vlax-for lo (vla-get-Layouts Doc)
            (vlax-for obj (vla-get-Block lo)
                (if (setq tempList (assoc (vla-get-Color obj) LwClrList))
                    (vla-put-Lineweight obj (cdr tempList))
                )
            )
        )
    )
    (LineweightByColor
        (vla-get-ActiveDocument (vlax-get-Acad-Object))
        (list
            '(1 . 16)
            '(2 . 7)
            '(3 . 14)
            '(4 . 24)
            '(5 . 2)
            '(6 . 31)
            '(7 . 6)
            '(8 . 2)
        )
    )

  3. #3
    Member
    Join Date
    2008-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Command: 'VLIDE OOPS: Automation Error. Invalid lineweight valueOOPS:
    Automation Error. Invalid lineweight value

  4. #4
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Change an object to the lineweight within the properties dialog, then run this on it and see what it says as the lineweight.

    Code:
    (vlax-dump-object
        (vlax-ename->vla-object
            (car (entsel "\n Select object to dump properties to the command line: "))
        )
        T
    )

  5. #5
    Member
    Join Date
    2008-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Color was pen 2 or yellow and this is what it says that lineweight is.

    Lineweight = 18

  6. #6
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Quote Originally Posted by fcfcadd View Post
    Color was pen 2 or yellow and this is what it says that lineweight is.

    Lineweight = 18
    So you might have to assign an object to each lineweight, and then use the second code posted to get the number to update the list in the first code. Once you get the numbers you want, just change the second number in the list.

    Hope that makes sense.

  7. #7
    Member
    Join Date
    2008-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    I'll give it a try. Thanks.

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Quote Originally Posted by fcfcadd View Post
    I'll give it a try. Thanks.
    You're welcome. Let us know if it doesn't work the way you think i should.

  9. #9
    Member
    Join Date
    2008-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    Code:
    (vl-load-com)
    (defun LineweightByColor (Doc LwClrList / )
        
        (vlax-for lo (vla-get-Layouts Doc)
            (vlax-for obj (vla-get-Block lo)
                (if (setq tempList (assoc (vla-get-Color obj) LwClrList))
                    (vla-put-Lineweight obj (cdr tempList))
                )
            )
        )
    )
    (LineweightByColor
        (vla-get-ActiveDocument (vlax-get-Acad-Object))
        (list
            '(1 . 40)
            '(2 . 18)
            '(3 . 35)
            '(4 . 60)
            '(5 . 5)
            '(6 . 80)
            '(7 . 15)
            '(8 . 5)
    This is what it returns now

    OOPS: malformed list on input
    _$

    Last edited by Opie; 2008-05-13 at 08:52 PM. Reason: [CODE] tags added, see Moderator Note

  10. #10
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Assign Lineweight per color not layer

    You don't finish the list, or the call to the program. You need to add two closing parenthesis, and then it won't be a malformed list anymore.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2015-02-16, 07:53 PM
  2. CTB lineweight vs. Layer List lineweight
    By mcasella in forum AutoCAD General
    Replies: 1
    Last Post: 2007-11-08, 01:02 PM
  3. assign layer lineweights based on layer color
    By viv.howe in forum AutoLISP
    Replies: 4
    Last Post: 2007-05-01, 04:27 PM
  4. assign layer lineweight based on layer color
    By kjbusacker in forum AutoLISP
    Replies: 9
    Last Post: 2007-03-01, 03:15 PM
  5. assign color to layer
    By ccowgill in forum AutoLISP
    Replies: 14
    Last Post: 2005-11-14, 02:10 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
  •