+ Reply to Thread
Results 1 to 7 of 7

Thread: Setbylayer Lisp

  1. #1
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 7; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2013
    Join Date
    Feb 2009
    Location
    Overland Park, KS
    Posts
    303

    Default Setbylayer Lisp

    Registered forum members do not see this ad.

    I am trying to incoporate this command (setbylayer) into a lisp routine that I am making to clean up our xrefs. I am trying to adjust the settings to change only the color, select all objects in the drawing, change byblock to bylayer, and to include blocks. Any help would be appreciated.

  2. #2
    Forum Deity
    Using
    AutoCAD 2009
    Join Date
    Oct 2008
    Posts
    2,112

    Default

    Quote Originally Posted by ksperopoulos View Post
    I am trying to incoporate this command (setbylayer) into a lisp routine that I am making to clean up our xrefs. I am trying to adjust the settings to change only the color, select all objects in the drawing, change byblock to bylayer, and to include blocks. Any help would be appreciated.
    For starters you could look into SETBYLAYERMODE variable.


    SETBYLAYERMODE

    Type: Integer
    Saved in: Registry
    Initial value: 127

    From the AutoCAD Help Section under system variables.

    Controls which properties are selected for SETBYLAYER

    The setting is stored as an integer using the sum of the following values:

    0 No properties are selected
    1 Color property
    2 Linetype property
    4 Lineweight property
    8 Material property
    16 Plot Style property
    32 Changes ByBlock to Bylayer
    64 Includes blocks when changing ByBlock to ByLayer

    There is also other information there not shown here.

    Also look into ssget in the Developer Help Section

    Creates a selection set from the selected object

    (ssget [sel-method] [pt1 [pt2]]
    [pt-list] [filter-list])
    Selection sets can contain objects from both paper and model space, but when the selection set is used in an operation, ssget filters out objects from the space not currently in effect. Selection sets returned by ssget contain main entities only (no attributes or polyline vertices).

    Maybe this thread will give you some idea:http://www.cadtutor.net/forum/showth...T+BYLAYER+LISP

  3. #3
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 7; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2013
    Join Date
    Feb 2009
    Location
    Overland Park, KS
    Posts
    303

    Default

    How is this. (FYI - I am a novice at this stuff)

    Code:
     
    (defun c:cleanxref2 ()
       (command "setvar" "cmdecho" 0)(command "setbylayermode" "1")
       (command "setvar" "cmdecho" 0)(command "setbylayer" "all" "" "y" "y")(princ))

  4. #4
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 7; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2013
    Join Date
    Feb 2009
    Location
    Overland Park, KS
    Posts
    303

    Default

    The setbylayer command doesn't seem to get dimensions that have the text set to a different color. Is there a setting in this command that can access all annotation items in a drawings as well as all the other items this command is changing to bylayer?

  5. #5
    Forum Deity
    Using
    AutoCAD 2009
    Join Date
    Oct 2008
    Posts
    2,112

    Default

    Quote Originally Posted by ksperopoulos View Post
    The setbylayer command doesn't seem to get dimensions that have the text set to a different color. Is there a setting in this command that can access all annotation items in a drawings as well as all the other items this command is changing to bylayer?
    That because its part of a named dimstyle. In that case you would need to get a selection set of all dimensions and change the dimstyle variables of the named dimstyle to bylayer. Seems you will have some addtional coding to do.


    Dimension Text: DIMCLRT
    Dimension Lines: DIMCLRD
    Dimension Ext Lines: DIMCLRE

  6. #6
    Forum Deity
    Using
    AutoCAD 2009
    Join Date
    Oct 2008
    Posts
    2,112

    Default

    ksperopoulos,

    Below is a code that I found on Afralisp http://www.afralisp.net/archive/lisp/clay.htm that touches the subject of setting entities color properties to bylayer. There are other areas such as linetype and blocks to give you a better idea on how to proceed. Once you get the idea with this code, The rest should become easier I hope. Afralisp has a great way of explaining things in simple terms to make it easier to learn. For linetypes and blocks you can find coding on Afralisp as well. You can refine them to your need as you see fit.

    This code deals with setting color on most general entities.
    I just changed the long name from ColorToLayer.lsp to CTL.lsp.
    Code:
    ;CODING BEGINS HERE
    
    (defun c:CTL ()
      (setq i 0 n 0)                                            ;clear the loop control variables
      (prompt "\n Select entities to analyze ")                 ;prompt the user
      (setq sel (ssget))                                        ;get the selection set
      (setq n (sslength sel))                                   ;get the number of objects
      (repeat n                                                 ;start the loop
        (setq entity (ssname sel i))                            ;get the entity name
        (setq name (entget entity))                             ;now get the entity list
        (if (not (assoc 6 name))                                ;if not Bylayer
          (progn                                                ;do the following
            (setq layer (cdr (assoc 8 name)))                   ;retrieve the layer name
            (setq layerinf (tblsearch "LAYER" layer))           ;get the layer data
            (setq layercol (cdr (assoc 62 layerinf)))           ;extract the default layer colour
            (setq name (append name (list (cons 62 layercol)))) ;construct an append the new list
            (entmod name)                                       ;update the entity
            (entupd entity)                                     ;update the screen
          )                                                     ;progn
        )                                                       ;if
        (setq i (1+ i))                                         ;increment the counter
      )                                                         ;repeat
      (princ))                                                  ;defun
    (princ)
    
    ;CODING END HERE

  7. #7
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 7; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2013
    Join Date
    Feb 2009
    Location
    Overland Park, KS
    Posts
    303

    Default

    Registered forum members do not see this ad.

    Thanks Buzzard! I've got a lot to learn.

Similar Threads

  1. Lisp Lisp path
    By jan_ek in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 10th May 2010, 04:08 pm
  2. a lisp to apply 3 different lisp to 3 obj types filtered from one selection
    By gilsoto13 in forum AutoLISP, Visual LISP & DCL
    Replies: 28
    Last Post: 5th Nov 2009, 05:28 am
  3. Running a lisp in another lisp??
    By neekcotrack in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 26th Aug 2008, 04:02 am
  4. Lisp Call Lisp Problem
    By neekcotrack in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 23rd Aug 2008, 12:56 pm
  5. problem, trying to running a list of lisp from within a lisp
    By twind2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Aug 2007, 04:27 pm

Bookmarks

Posting Permissions

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