AutoLisp Chapter - 5

AutoLisp Chapter - 5
Site menu


Login form


Search


Site friends
  • Create your own site


  • Statistics

    Total online: 1
    Guests: 1
    Users: 0


    Welcome, Guest ยท RSS 03 December 2024
    AutoLisp Tutorial for Intermediate
     

    Chapter - 5
     
     
    Topics Coverd In this Chapter
    •  Selection Sets


    Select Objects - Selection Sets
     
    In Autocad When you Run Command Like Copy, Move Autocad first ask for Select single or group of objects. you can use multiple option to select or deselect a single or group of objects. the objects you selected is called Selection Set. you can use ssget function to do it with Autolisp. when ssget is used the selection prompt is appear and user can asked to select a single or group of object tobe processed later in your program.
     
    the syntax for ssget is
     
    (ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])
     

    sel-method (Optional)

     A string that specifies the object selection method. Valid selection methods are

     C Crossing selection.

     CP Cpolygon selection (all objects crossing and inside of the specified polygon).

     F Fence selection.

     I Implied selection (objects selected while PICKFIRST is in effect).

     L Last visible object added to the database.

     P Last selection set created.

     W Window selection.

     WP WPolygon (all objects within the specified polygon).

     X Entire database. If you specify the X selection method and do not provide a filter-list, ssget selects all entities in the database, including entities on layers that are off, frozen, and out of the visible screen.

     :E Everything within the cursor's object selection pickbox.

     :N Call ssnamex for additional information on container blocks and transformation matrices for any entities selected during the ssget operation. This additional information is available only for entities selected via graphical selection methods such as Window, Crossing, and point picks.

     :S Allow single selection only.

     :U Enables subentity selection. Cannot be combined with the duplicate (":D") or nested (":N") selection modes. In this mode, top-level entities are selected by default, but the user can attempt to select subentities by pressing the CTRL key while making the selection. This option is supported only with interactive selections, such as window, crossing, and polygon. It is not supported for all, filtered, or group selections.

     :V Forces subentity selection. Treats all interactive, graphic selections performed by the user as subentity selections. The returned selection set contains subentities only. This option cannot be combined with the duplicate (":D") or nested (":N") selection modes. This option is supported only with interactive selections, such as window and crossing. It is not supported for all, filtered, or group selections.

    pt1 (optional)

     A point relative to the selection.

    pt2 (optional)

     A point relative to the selection.

    pt-list (optional)

     A list of points.

    filter-list (optional)

     An association list that specifies object properties. Objects that match the filter-list are added to the selection set.
     
    The optional argument shows the way which you want to use for select a object. if you want to use previous selection you may specify "P", or you want to use Cross window you may use "C". lets look some Example
     
     
    You can also specify points either to select objects at a known location or as input to the window or crossing mode options. For example, if you want to select an object you know is at point 1,1, you can place the following in your program:
     (setq SSET (ssget '(1 1)))

    You can also indicate a window by indicating two point as in the following:

    (setq SSET (ssget "W" '(0 0) '(10 15)))
     Point specification need not be in the form of a quoted list. You can supply a variable as well. Suppose two points have been previously defined in your program:
     
    (setq pt1 (getpoint "Pick a point: "))
     
    (setq Pt2 (getcorner pt1 "Pick another point: "))
     
    The periods in the sample above indicate other expressions in your program Later in your program, You can then use those two point to select objects with a window:
     
    (setq obj1 (ssget "W" pt1 pt2))  

    If you provide points as arguments, however, ssget does not pause for user input. It assumes that the points provided as arguments indicate the location of the objects to be included in the selection set.

     Finally, if you do not provide any arguments, ssget will allow the user to select the mode of selection. If the following appears in your program:
     
    (setq obj1 (ssget))
     
    Ssget displays the prompt:
     
    Select objects:

     The user can either pick objects with a single pick, or enter W or C to select a standard or crossing window. The use can also use the Remove mode to de-select objects during the selection process. In fact, all the standard object selection options are available. When the user is done, he or she can press return to confirm the selection.

    Filter List
     
    if your program want to select only text for processing you can specity it with filter list argument. An entity filter list is an association list that uses DXF group codes. lets look some examples
     
    (setq sset (ssget '((0 . "TEXT"))))
     
    (setq sset (ssget '((0 . "LINE") (8 . "wall"))))
     
    here are some of Common DXF group code list
     
     
     
    Group codes that apply to all graphical objects
    Group code
    Description
    0
    Entity type
    8
    Layer name
    6
    Linetype name (present if not BYLAYER). The special name BYBLOCK indicates a floating linetype (optional)
    62
    Color number (present if not BYLAYER); zero indicates the BYBLOCK (floating) color; 256 indicates BYLAYER; a negative value indicates that the layer is turned off (optional)
    370
    Lineweight enum value. Stored and moved around as a 16-bit integer.
    48
    Linetype scale (optional)
     
    3 = Ignores shadows
     
     
    Sample Program
     

    (defun c:selset ()

    (defun c:selset ()

    (setq txtset (ssget '((0 . "TEXT")))) ;;;Create Selection set of text

    (setq lineset (ssget '((0 . "LINE")(8 . "0")))) ;; create selction set of line in layer "0" 

    )