+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Junior Member
    Using
    AutoCAD 2012
    Join Date
    Jan 2012
    Posts
    12

    Default Help me finish this LISP please

    With this LISP Im trying to make under floor heating.

    I think i am close to finishing it, but some error occurs in the end.

    Im trying to explode the last selection set but to do that google told me that you need to (setvar "qaflags" 1), and i think it's there that i don't follow.

    What is wrong and how to solve it?

    Please note that Im new to LISP and programming in general.

    If you took an extra minute to explain what i did wrong i would really appreciate it.

    Also, Im sorry if the code looks really bad, as i said i am new to this.

    Attaching a .dwg containing a block that is used in the lisp, so you can try it.

    gv.dwg

    Code:
    (defun c:gt (/ lastEnt ss)
      ;; Save the last entity
      (setq lastEnt (entlast))
      ;; Underfloorheatinghorizontal
      
       
     
    
    
        (setq pt1 (getdist "\nSpecify length of room"))
    
        (setq pt2 (getdist "\nSpecify height of room"))
        
        (setq pt3 (getpoint "\nSpecify lower middlepoint of room"))
        
      (command "-insert" "1" "x" (-(* pt1 3) 300) "y" "300" pt3 "0")
      (command "move" "l" "" "d" "0,50,0")
      
    
    ;;; ROUND
    ;;; (round pi 0.01) -> 3.14
    ;;; (round pi 1e-5) -> 3.14159
    ;;; (round 5456.50 1) -> 5457
    ;;; (round 5456.50 100) -> 5500
    
    (defun round (num prec)
      (* prec
         (if (minusp num)
           (fix (- (/ num prec) 0.5))
           (fix (+ (/ num prec) 0.5))
         )
      )
    )
    
    
       (command "_array" "l" "" "rectangular" (round (/ pt2 600) 1) "1" "600")
       
       
    
     (setq ss (ssadd))
      (while (setq lastEnt (entnext lastEnt))
        (ssadd lastEnt ss)
    
    
    (sssetfirst nil ss) ;Grip select the set
      
      (setq OldQa (getvar "QAFLAGS" ) )
      (setvar "QAFLAGS" 5 )
      
        (command "._explode" SelSet)
      
      (setvar "QAFLAGS" OldQa )
       
    
      )
    
       
    
      (princ)
    )

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,605

    Default

    Code:
    (defun c:gt  (/ lastEnt ss)
          (setq pt1 (getdist "\nSpecify length of room"))
          (setq pt2 (getdist "\nSpecify height of room"))
          (setq pt3 (getpoint "\nSpecify lower middlepoint of room"))
          (command
                "-insert"
                "1"
                "x"
                (- (* pt1 3) 300)
                "y"
                "300"
                pt3
                "0")
          (command "move" "l" "" "d" "0,50,0");<not sure whats this for
          (defun round  (num prec)
                (* prec
                   (if (minusp num)
                         (fix (- (/ num prec) 0.5))
                         (fix (+ (/ num prec) 0.5))
                         )
                   )
                )
          (setq lastEnt (entlast)
                ss      (ssadd))
          (command "._explode" "L" "")
          (command
                "_-array"
                "P"
                ""
                "rectangular"
                (round (/ pt2 600) 1)
                "1"
                "600")
          (while (setq lastEnt (entnext lastEnt))
                (ssadd lastEnt ss))
     (sssetfirst nil ss)               ;Grip select the set
          (princ)
          )

  3. #3
    Junior Member
    Using
    AutoCAD 2012
    Join Date
    Jan 2012
    Posts
    12

    Default

    The move command is because i couldnt figure out how to use 50y above pt3.

    Wow, thank you it does seem to work now.

    I still cant figure out how to select created items for use in next commands. I would also like to pedit the selection and fillet it with a radius of 150.

    Any input on that?

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,605

    Default

    Use variable ss

    Code:
    (defun c:gt  (/ lastEnt ss pt1 pt2 pt3 i e ang)
    (defun round  (num prec)
        (* prec
           (if (minusp num)
                 (fix (- (/ num prec) 0.5))
                 (fix (+ (/ num prec) 0.5))
                 )
           )
        )
    (if (and      
          (setq pt1 (getdist "\nSpecify length of room"))
          (setq pt2 (getdist "\nSpecify height of room"))
          (setq pt3 (getpoint "\nSpecify lower middlepoint of room"))
          )
        (progn
              (command
                    "-insert"
                    "1"
                    "x"
                    (- (* pt1 3) 300)
                    "y"
                    "300"
                    pt3
                    "0")
              (command "move" "l" "" "d" "0,50,0")
                                            ;<not sure whats this for
              (setq lastEnt (entlast)
                    ss      (ssadd))
              (command "._explode" "L" "")
              (command
                    "_-array"
                    "P"
                    ""
                    "rectangular"
                    (round (/ pt2 600) 1)
                    "1"
                    "600")
              (while (setq lastEnt (entnext lastEnt))
                    (ssadd lastEnt ss))
                                            ;(sssetfirst nil ss)
              (repeat (setq i (sslength ss))
                  (setq e   (ssname ss (setq i (1- i)))
                        Ang (apply 'angle
                                   (setq se   (mapcar '(lambda (j)
                                                             (cdr (assoc j (entget e))))
                                                      '(10 11)))))
                  (if (not (apply 'or (mapcar 'zerop (list i ang))))
                        (progn
                              (entmakex
                                    (list (cons 0 "ARC")
                                          (cons 10 (mapcar
                                                      (function
                                                            (lambda (a b) (/ (+ a b) 2.)))
                                                      (car se)
                                                      (cadr se)))
                                          '(40 . 150)
                                          (cons 50 (if   (equal
                                                            ang
                                                            (/ pi  2.0)  0.1)
                                                           (* pi 1.5)
                                                           (/ pi 2.0)))
                                          (cons 51 Ang)
                                          ))
                              (entdel e)
                              (ssdel e ss)
                              (ssadd (entlast) ss)
                              )
                        )
                  )
            (command "_pedit" "_multiple" ss "" "_Yes" "_join" "" "")
            )
     
        )
     
          (princ)
     
          )
    Not sure if this is what you want though.

    EDIT: if you guys are wondeering about this
    (not (apply 'or (mapcar 'zerop (list i ang))))

    On testing phase (since i'm unsure of the OPS final result will be) I redfined block "i" from his example drawing (not attached here). that way the first vertical line will remain and the rest would be an arc.
    Last edited by pBe; 29th Jan 2012 at 12:24 pm. Reason: info

  5. #5
    Junior Member
    Using
    AutoCAD 2012
    Join Date
    Jan 2012
    Posts
    12

    Default

    Registered forum members do not see this ad.

    Code:
    (repeat (setq i (sslength ss))
                  (setq e   (ssname ss (setq i (1- i)))
                        Ang (apply 'angle
                                   (setq se   (mapcar '(lambda (j)
                                                             (cdr (assoc j (entget e))))
                                                      '(10 11)))))
                  (if (not (apply 'or (mapcar 'zerop (list i ang))))
                        (progn
                              (entmakex
                                    (list (cons 0 "ARC")
                                          (cons 10 (mapcar
                                                      (function
                                                            (lambda (a b) (/ (+ a b) 2.)))
                                                      (car se)
                                                      (cadr se)))
                                          '(40 . 150)
                                          (cons 50 (if   (equal
                                                            ang
                                                            (/ pi  2.0)  0.1)
                                                           (* pi 1.5)
                                                           (/ pi 2.0)))
                                          (cons 51 Ang)
                                          ))
                              (entdel e)
                              (ssdel e ss)
                              (ssadd (entlast) ss)
                              )
                        )
                  )
    I have no idea what happens here but it does the job. Thank you so much for the help. I have to get to reading now so i will understand what the code does there.

Similar Threads

  1. solidworks/flat to finish
    By maddbomber in forum SolidWorks
    Replies: 2
    Last Post: 3rd Feb 2009, 01:46 pm
  2. AutoCAD 2009 Fit & Finish
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 22nd Aug 2008, 05:30 pm
  3. Clicking to finish a command
    By benfell in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 18th Dec 2007, 01:31 am
  4. Rock Veneer Finish
    By eduardo75 in forum AutoCAD General
    Replies: 0
    Last Post: 15th May 2006, 10:13 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