+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    j_r_auden
    Guest

    Default selecting an object

    Registered forum members do not see this ad.

    I am using
    (setq myobject(ssget "_:S"))
    to get a single object from the user. However, if the user clicks on empty
    space the function simply continues and produces an error later. How can I get my function to wait until the user actually chooses a valid object. Like the "break" function for example. If you don't select an item, you are asked to select an object again.

    Thanks for the help

  2. #2
    Administrator CADTutor's Avatar
    Computer Details
    CADTutor's Computer Details
    Operating System:
    Windows 7 Home Premium 64bit
    Motherboard:
    Asus P7P55D-E PRO
    CPU:
    Intel Core i7-860
    RAM:
    4GB PC3-12800 C8 Corsair Dominator
    Graphics:
    NVIDIA Quadro FX 1800 768 MB
    Primary Storage:
    Intel X25-M SSD 160GB
    Secondary Storage:
    Samsung Spinpoint 320GB
    Monitor:
    BenQ FP241W 24" Wide
    Discipline
    Education
    CADTutor's Discipline Details
    Occupation
    Senior Lecturer (Digital Design), Landscape Architect & Web Designer
    Discipline
    Education
    Using
    AutoCAD 2014
    Join Date
    Aug 2002
    Location
    Hampshire, UK
    Posts
    3,606

    Default

    You need to put your selection function within a while loop that tests to see if an object has been selected. Here's an example:

    Code:
    (setq obj nil)
    (while (= obj nil)
    	(setq obj (entsel "\nSelect object: "))
    )
    Now it's quite some time since I did any serious LISPing and so there may be a more modern way to go about this but it does work. The user will continue to be prompted until an object is selected.

    If you only want a single object, entsel is simpler than ssget because no selection set is required.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
    AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

  3. #3
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    I still prefer (sssget) over (entsel)

    Code:
    (while (or (not ss)
                   (> (sslength ss) 1))
               &#40;princ "\nSelect 1 <filtered> object&#58;   "&#41;
               &#40;setq ss &#40;ssget &#41;&#41;&#41;  ;include filter list
    &#40;setq obj &#40;ssname ss 0&#41;&#41;
    -David
    R12 (Dos) - A2K

  4. #4
    Fantomas
    Guest

    Default

    One more example with ENTSEL and filter with MEMBER function.

    Code:
    &#40;while
      &#40;not
        &#40;and
          &#40;setq obj&#40;car&#40;entsel "\nSelect text object or Esc to Quit "&#41;&#41;&#41;
          &#40;member&#40;cdr&#40;assoc 0&#40;entget obj&#41;&#41;&#41; '&#40;"TEXT" "MTEXT" "ATTRIBUTE"&#41;&#41;
          &#41;; end and
        &#41;; not
      &#41;; end while

  5. #5
    Administrator CADTutor's Avatar
    Computer Details
    CADTutor's Computer Details
    Operating System:
    Windows 7 Home Premium 64bit
    Motherboard:
    Asus P7P55D-E PRO
    CPU:
    Intel Core i7-860
    RAM:
    4GB PC3-12800 C8 Corsair Dominator
    Graphics:
    NVIDIA Quadro FX 1800 768 MB
    Primary Storage:
    Intel X25-M SSD 160GB
    Secondary Storage:
    Samsung Spinpoint 320GB
    Monitor:
    BenQ FP241W 24" Wide
    Discipline
    Education
    CADTutor's Discipline Details
    Occupation
    Senior Lecturer (Digital Design), Landscape Architect & Web Designer
    Discipline
    Education
    Using
    AutoCAD 2014
    Join Date
    Aug 2002
    Location
    Hampshire, UK
    Posts
    3,606

    Default

    Ah, there you see - I knew there would be a number of different opinions on this and I'm sure that Fuccaro will add another when he sees this.

    David, why do you prefer ssget over entget. It seems more complicated?
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
    AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

  6. #6
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    Always you can add extras but a simple SSGET works fine for me...
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  7. #7
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    CadTutor,

    I've always prefered (ssget) due to fact that you can use Last/Prev/ etc whereas (entsel) is pretty limited. Also (ssget) filtering is a lot is a lot cleaner (IMO ) than after selection entity testing. -David
    R12 (Dos) - A2K

  8. #8
    Fantomas
    Guest

    Default

    In most cases I too prefer SSGET. However sometimes from aesthetic reasons I use ENTSEL. It is not pleasant to me that at a choice of one object with an option " _:S " the choice by a frame enabled and an inscription ' Select objects:'.

  9. #9
    Administrator CADTutor's Avatar
    Computer Details
    CADTutor's Computer Details
    Operating System:
    Windows 7 Home Premium 64bit
    Motherboard:
    Asus P7P55D-E PRO
    CPU:
    Intel Core i7-860
    RAM:
    4GB PC3-12800 C8 Corsair Dominator
    Graphics:
    NVIDIA Quadro FX 1800 768 MB
    Primary Storage:
    Intel X25-M SSD 160GB
    Secondary Storage:
    Samsung Spinpoint 320GB
    Monitor:
    BenQ FP241W 24" Wide
    Discipline
    Education
    CADTutor's Discipline Details
    Occupation
    Senior Lecturer (Digital Design), Landscape Architect & Web Designer
    Discipline
    Education
    Using
    AutoCAD 2014
    Join Date
    Aug 2002
    Location
    Hampshire, UK
    Posts
    3,606

    Default

    Fantomas, you and I are on the same wavelength, Entget is certainly more elegant for selecting a single object. Irrespective of other considerations it is just more beautiful and anyone who has done any programming/scripting should look for beauty in their code - don't you think?

    Certainly it is potentially confusing for the user to be asked to "select objects" when only one object is required.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
    AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

  10. #10
    Fantomas
    Guest

    Default

    Registered forum members do not see this ad.

    Yes I too such opinion. Unfortunately AutoLISP not always allows to make all beautifully. For example DCL is a parody on HTML, it is necessary to use ObjectDCL and others libruaries for example DosLib. But it limits representation of such programs at forums because demands from the user of loading additional *.arx files.

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