Jump to content

Recommended Posts

Posted (edited)

That works.

 

I added the output file part. I get "malformed list on input". I don't know how to fix it.

 

I've tried a space between lines 3 and 4 as well as putting it in other locations. What am i missing?

 

(defun c:Test (/ ss)
 (vl-load-com)
 (if (setq f (getfiled "Output File" "" "xls" 1))
 (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
   ((lambda (i n / lst e)
      (while (> (setq n (1- n)) 0) (setq lst (cons n lst)))
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq lst (vl-remove
                    (atoi (vl-list->string
                            (vl-remove 34 (vl-string->list (cdr (assoc 1 (entget e)))))
                          )
                    )
                    lst
                  )
        )
      )
      (cond (lst (print lst)))
    )
     -1
     211
   )
 )
 (princ)
)

Edited by pinkguju
Forgot the # for the code.
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • pinkguju

    10

  • Lee Mac

    8

  • alanjt

    4

  • BlackBox

    3

Top Posters In This Topic

Posted Images

Posted

For starters, you were missing a paren. Are you using the VLIDE to check your code?

 

I just glanced at your code, and here's a couple revisions that jumped out to me:

 

(defun c:Test  (/ f ss)
 (vl-load-com)
 (if (and (setq f (getfiled "Output File" "" "xls" 1))
          (setq ss
                 (ssget
                   "_X"
                   '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))))
   ((lambda (i n / lst e)
      (while (> (setq n (1- n)) 0) (setq lst (cons n lst)))
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq lst
               (vl-remove
                 (atoi
                   (vl-list->string
                     (vl-remove
                       34
                       (vl-string->list (cdr (assoc 1 (entget e)))))))
                 lst)))
      (cond (lst (print lst))))
     -1
     211))
 (princ))

 

 

I have not tested this, so if there's something else I've overlooked, I apologize.

Posted
(defun c:Test (/ file ss)
 ;; Alan J. Thompson
 (vl-load-com)
 (if (and (setq file (getfiled "Output File" "" "xls" 1))
          (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
     )
   ((lambda (i n / lst e)
      (while (> (setq n (1- n)) 0) (setq lst (cons n lst)))
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq lst (vl-remove
                    (atoi (vl-list->string
                            (vl-remove 34 (vl-string->list (cdr (assoc 1 (entget e)))))
                          )
                    )
                    lst
                  )
        )
      )
      (cond (lst (print lst) (AT:WriteToFile file lst T)))
    )
     -1
     211
   )
 )
 (princ)
)


(defun AT:WriteToFile (file lst overwrite / fo)
 ;; Write list to file
 ;; file - file to write list to (must be in form "c:\\File.txt")
 ;; lst - list to write to file
 ;; overwrite - If T, will overwrite; nil to append
 ;; Alan J. Thompson, 04.28.09
 (if (and (vl-consp lst)
          (setq fo (open file
                         (if overwrite
                           "W"
                           "A"
                         )
                   )
          )
     )
   (progn (foreach x lst (write-line (vl-princ-to-string x) fo))
          (close fo)
          file
   )
 )
)

Posted
; error: no function definition: AT:WRITETOFILE

Scroll down and copy everything. :wink:

Posted
Scroll down and copy everything. :wink:

 

I deleted the post before I got your notification... I overlooked the scrollbar handle.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...