Results 1 to 6 of 6

Thread: Help with while loop, layer lineweight change

  1. #1
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Help with while loop, layer lineweight change

    I am trying to create a routine that will search through all layers in a drawing and assign a lineweight to each layer based on color. I haven't yet defined a function in the attached sample, but I can get it to change some layer information. Strangely, it changes only every other layer. I am wondering if that is because of the while statement and the relative position of the (setq flag nil) list. I did try moving it inside the loop, but the results were the same.

    Any help is greatly appreciated.

    Thanks,
    Attached Files Attached Files

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

    Default Re: Help with while loop, layer lineweight change

    This is how I would step through a table.

    (while (setq Lay (tblnext "layer" (not Lay)))
    ..... do what you want here
    )

    This way it will end the loop when you run out of layers.

  3. #3
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Re: Help with while loop, layer lineweight change

    Tim,

    Thanks for the response. Your solution works well, but for some reason, every other layer isn't assigned a width as it should be. I am assuming at this point that it has nothing to do with the loop, but the COND section. Any thoughts?

    Thanks again,

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

    Default Re: Help with while loop, layer lineweight change

    It's because you use two ' tblnext ' calls per layer.

    Code:
    (setq layer (tblnext "Layer" flag)) nil)
      (setq flag nil)
    (setq lname (cdr (assoc 2 (tblnext "Layer")))) ;get the layer name, save to variable
    What might be better is after ' layer ' is set, get the entity name of the layer, and assign that to the variable you want, like;

    (setq LayData (entget (tblobjname "layer" (cdr (assoc 2 layer)))))

    Then use ' LayData ' to change all the things you need.

  5. #5
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Re: Help with while loop, layer lineweight change

    Tim,

    That was it. I just used the layer variable to set the layer name and then it ran like a dream.

    Many Thanks,

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

    Default Re: Help with while loop, layer lineweight change

    Quote Originally Posted by jeff.richards View Post
    Tim,

    That was it. I just used the layer variable to set the layer name and then it ran like a dream.

    Many Thanks,
    Glad to hear that Jeff. You're welcome.

Similar Threads

  1. LineWeight Loopidy-Loop
    By freedomonek in forum AutoLISP
    Replies: 14
    Last Post: 2009-05-22, 06:10 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. Replies: 10
    Last Post: 2007-04-27, 06:17 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. How do you change the lineweight of the schedule grid?
    By hdjohnson in forum Revit Architecture - General
    Replies: 10
    Last Post: 2004-07-31, 10:55 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
  •