+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member 3dwannab's Avatar
    Computer Details
    3dwannab's Computer Details
    Operating System:
    Windows 7 Ultimate x64
    Computer:
    Self-Built
    Motherboard:
    Rampage II Extreme
    CPU:
    Intel(R) Core(TM) i7 CPU 965 @ 3.20GHz
    RAM:
    Corsair 12GB DDR3 XMS3 PC3-12800C9 1600MHz
    Graphics:
    ATI Radeon HD 4870 X2
    Primary Storage:
    512GB SSD
    Secondary Storage:
    2 x WD VelociRaptor 1000 GB Hard Drives @ 7,200RPM
    Monitor:
    32" HP LP3065 Wide LCD Moniter + 24" Dell
    Discipline
    Architectural
    3dwannab's Discipline Details
    Occupation
    arch technician and arch viz
    Discipline
    Architectural
    Details
    Office Tea Maker
    Using
    AutoCAD 2017
    Join Date
    Jun 2012
    Location
    Ireland
    Posts
    118

    Default Select objects in current layer

    Registered forum members do not see this ad.

    Code:
    (sssetfirst nil (ssget "_X" '((8 . "5"))))
    will select objects in layer 5 no problem but when i incorporate
    Code:
    (getvar "CLAYER")
    to make:
    Code:
    (sssetfirst nil (ssget "_X" '((8 . (getvar "CLAYER")))))
    It comes back with error: ; error: bad SSGET list value

    It's probably just a simple fix (heck, maybe even a standard command to do the same)

    Thanks in advance.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,364

    Default

    See if you can work out why from my tutorial The Apostrophe and the Quote Function
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Senior Member 3dwannab's Avatar
    Computer Details
    3dwannab's Computer Details
    Operating System:
    Windows 7 Ultimate x64
    Computer:
    Self-Built
    Motherboard:
    Rampage II Extreme
    CPU:
    Intel(R) Core(TM) i7 CPU 965 @ 3.20GHz
    RAM:
    Corsair 12GB DDR3 XMS3 PC3-12800C9 1600MHz
    Graphics:
    ATI Radeon HD 4870 X2
    Primary Storage:
    512GB SSD
    Secondary Storage:
    2 x WD VelociRaptor 1000 GB Hard Drives @ 7,200RPM
    Monitor:
    32" HP LP3065 Wide LCD Moniter + 24" Dell
    Discipline
    Architectural
    3dwannab's Discipline Details
    Occupation
    arch technician and arch viz
    Discipline
    Architectural
    Details
    Office Tea Maker
    Using
    AutoCAD 2017
    Join Date
    Jun 2012
    Location
    Ireland
    Posts
    118

    Default

    Quote Originally Posted by Lee mAC View Post
    mAC;633024]See if you can work out why from my tutorial The Apostrophe and the Quote Function
    Sorry, maybe having a slow day but I can't get that to work. Have tried which seems like the most logical solution:
    Code:
    (setq ss (getvar "CLAYER"))
    (sssetfirst nil (ssget "_X" '((8 . (list ss)))))
    from this example:
    Code:
    _$ (setq x 5)
    5
    _$ (list 1 2 3 4 x)
    (1 2 3 4 5)
    I'm learning maxscript also and find it much more user friendly to learn.

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,364

    Default

    Refer to the ssget example in this section - remember that any expression following a quote/apostrophe will not be evaluated.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Senior Member 3dwannab's Avatar
    Computer Details
    3dwannab's Computer Details
    Operating System:
    Windows 7 Ultimate x64
    Computer:
    Self-Built
    Motherboard:
    Rampage II Extreme
    CPU:
    Intel(R) Core(TM) i7 CPU 965 @ 3.20GHz
    RAM:
    Corsair 12GB DDR3 XMS3 PC3-12800C9 1600MHz
    Graphics:
    ATI Radeon HD 4870 X2
    Primary Storage:
    512GB SSD
    Secondary Storage:
    2 x WD VelociRaptor 1000 GB Hard Drives @ 7,200RPM
    Monitor:
    32" HP LP3065 Wide LCD Moniter + 24" Dell
    Discipline
    Architectural
    3dwannab's Discipline Details
    Occupation
    arch technician and arch viz
    Discipline
    Architectural
    Details
    Office Tea Maker
    Using
    AutoCAD 2017
    Join Date
    Jun 2012
    Location
    Ireland
    Posts
    118

    Default

    Quote Originally Posted by Lee Mac View Post
    Refer to the ssget example in this section - remember that any expression following a quote/apostrophe will not be evaluated.
    Thanks. Maybe my brain isin't all there today but looking at your example didn't help. I still know you're the LISP master

    I found this link here in the help: http://exchange.autodesk.com/autocad...7a53f-7a31.htm

    I've came up with three variations which do the same thing

    Code:
    (setq lay_name (getvar "CLAYER"))
    (setq ss1 (ssget "_X" (list (cons 8 lay_name))))
    (command "pselect" "P" "")
    
    ------------------------------------
    
    (setq ss1 (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
    (command "pselect" ss1 "")
    
    ------------------------------------
    
    (ssget "_X" (list (cons 8 (getvar "CLAYER"))))
    (command "pselect" "P" "")
    Thanks for your help.

  6. #6
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    735

    Default

    Quote Originally Posted by 3dwannab View Post
    Thanks. Maybe my brain isin't all there today but looking at your example didn't help. I still know you're the LISP master

    I found this link here in the help: http://exchange.autodesk.com/autocad...7a53f-7a31.htm

    I've came up with three variations which do the same thing

    Code:
    (setq lay_name (getvar "CLAYER"))
    (setq ss1 (ssget "_X" (list (cons 8 lay_name))))
    (command "pselect" "P" "")
    
    ------------------------------------
    
    (setq ss1 (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
    (command "pselect" ss1 "")
    
    ------------------------------------
    
    (ssget "_X" (list (cons 8 (getvar "CLAYER"))))
    (command "pselect" "P" "")
    Thanks for your help.
    Glad you found a solution, but Lee's link explains the quote function as well as any I've seen. Do you understand now that the difference between using quote -vs- the list and cons functions is that any expression following a quote/apostrophe will not be evaluated?

  7. #7
    Senior Member 3dwannab's Avatar
    Computer Details
    3dwannab's Computer Details
    Operating System:
    Windows 7 Ultimate x64
    Computer:
    Self-Built
    Motherboard:
    Rampage II Extreme
    CPU:
    Intel(R) Core(TM) i7 CPU 965 @ 3.20GHz
    RAM:
    Corsair 12GB DDR3 XMS3 PC3-12800C9 1600MHz
    Graphics:
    ATI Radeon HD 4870 X2
    Primary Storage:
    512GB SSD
    Secondary Storage:
    2 x WD VelociRaptor 1000 GB Hard Drives @ 7,200RPM
    Monitor:
    32" HP LP3065 Wide LCD Moniter + 24" Dell
    Discipline
    Architectural
    3dwannab's Discipline Details
    Occupation
    arch technician and arch viz
    Discipline
    Architectural
    Details
    Office Tea Maker
    Using
    AutoCAD 2017
    Join Date
    Jun 2012
    Location
    Ireland
    Posts
    118

    Default

    I do to some degree it will sink in eventually. I don't know want has happened but NONE of the examples I had working are working now. Commandline is now saying "Unknown command "PSELECT". Press F1 for help." All those were working perfectly beforehand.

    My lisp so far.
    Code:
    (defun c:SEL_LAYER_CURRENT ( / cmdecho )
        (setq  cmdecho (getvar 'cmdecho))
        (setvar 'cmdecho 0)
    
        (setq ss1 (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
        (command "pselect" ss1 "")
        ;;(princ (strcat "\n" (sslength ss1) " objects selected. "))
    
         
        ;;(print (sslength ss1))
    
        (setvar 'cmdecho cmdecho)
    )
    I also want to print the amount of selected objects after the command has finished but I having trouble joining up the text string and the amount of objects.

  8. #8
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    Eg.

    Code:
    (defun c:Test (/ s)
      (if (setq s (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
        (princ (strcat "\nNumber of Found objects : < " (itoa (sslength s)) " >"))
      )
      (sssetfirst nil s)
      (princ)
    )

  9. #9
    Senior Member 3dwannab's Avatar
    Computer Details
    3dwannab's Computer Details
    Operating System:
    Windows 7 Ultimate x64
    Computer:
    Self-Built
    Motherboard:
    Rampage II Extreme
    CPU:
    Intel(R) Core(TM) i7 CPU 965 @ 3.20GHz
    RAM:
    Corsair 12GB DDR3 XMS3 PC3-12800C9 1600MHz
    Graphics:
    ATI Radeon HD 4870 X2
    Primary Storage:
    512GB SSD
    Secondary Storage:
    2 x WD VelociRaptor 1000 GB Hard Drives @ 7,200RPM
    Monitor:
    32" HP LP3065 Wide LCD Moniter + 24" Dell
    Discipline
    Architectural
    3dwannab's Discipline Details
    Occupation
    arch technician and arch viz
    Discipline
    Architectural
    Details
    Office Tea Maker
    Using
    AutoCAD 2017
    Join Date
    Jun 2012
    Location
    Ireland
    Posts
    118

    Default

    Quote Originally Posted by Tharwat View Post
    Eg.

    Code:
    (defun c:Test (/ s)
      (if (setq s (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
        (princ (strcat "\nNumber of Found objects : < " (itoa (sslength s)) " >"))
      )
      (sssetfirst nil s)
      (princ)
    )
    Excellent Tharwat. I understand fully what all that code does. (I thought I tried itoa to convet it to a string!!) Thanks very much. I think this simple routine will take over the LAYWALK command for me. BTW it could be useful of it allowed the user to have the dialog open. Anyway this is great. Here's the code.

    Code:
    ;;---------------=={ 3DwannaB_Sel_Layer_Current.lsp }==-----------------;;
    ;;                                                                      ;;
    ;;  Selects All Objects On Current Later                                ;;
    ;;----------------------------------------------------------------------;;
    ;;  Author: 3DwannaB, Copyright © 2015                                  ;;
    ;;----------------------------------------------------------------------;;
    ;;  Version 1.0    -    23-05-2015                                      ;;
    ;;                                                                      ;;
    ;;  First Release. Lots of help from 'Lee Mac' Credit goes to 'Tharwat' ;;
    ;;  See http://bit.ly/1HzZrlM                                             ;;
    ;;                                                                      ;;
    ;;----------------------------------------------------------------------;;
    
    (defun c:SEL_LAYER_CURRENT (/ s cmdecho )
        (setq  cmdecho (getvar 'cmdecho))
        (setvar 'cmdecho 0)
            (if (setq s (ssget "_X" (list (cons 8 (getvar "CLAYER")))))
            (princ (strcat "\nNumber of Found objects : < " (itoa (sslength s)) " >"))
        )
        (sssetfirst nil s)
        (setvar 'cmdecho cmdecho)
        (princ)
    )
    ;;----------------------------------------------------------------------;;
    (princ
        (strcat
            "\n:: 3DwannaB_Sel_Layer_Current.lsp | Version 1.0 | by 3DwannaB  ::"
            "\n:: Type \"Sel_Layer_Current\" to Invoke                          ::"
        )
    )
    (princ)
    ;;----------------------------------------------------------------------;;
    ;;                             End of File                              ;;
    ;;----------------------------------------------------------------------;;

  10. #10
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by 3dwannab View Post
    Excellent Tharwat. I understand fully what all that code does. (I thought I tried itoa to convet it to a string!!) Thanks very much. I think this simple routine will take over the LAYWALK command for me. BTW it could be useful of it allowed the user to have the dialog open. Anyway this is great. Here's the code.
    You are most welcome .

    Can you tell me what is the need of the System Variable CMDECHO into the routine ?

Similar Threads

  1. select all objects on the current layer
    By motee-z in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 17th Dec 2015, 03:53 pm
  2. Select all objects in a single layer: how?
    By Sudan in forum AutoCAD Beginners' Area
    Replies: 11
    Last Post: 15th Sep 2015, 08:21 pm
  3. Select All Objects on a Certain Layer
    By resullins in forum AutoCAD General
    Replies: 4
    Last Post: 28th Dec 2011, 01:22 am
  4. Setting objects to current layer.
    By roberts in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 3rd Apr 2007, 04:55 pm
  5. Select Objects - Place on new layer.
    By FindAPath in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 28th Aug 2006, 10:37 pm

Tags for this Thread

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