Jump to content

Recommended Posts

Posted

Dear Masters,

 

what is the wrong in my lisp program.please find error message while using the code. kindly fix the error.

 

;___________________________________________________________________________________________________________
;
; Function to export a the coordinates of a group of points to excel (using csv file method)
;___________________________________________________________________________________________________________

(defun C:MirrorPoints (/ lstOfPoints lstSelections ssSelections strCSVFullName)
(if (and (setq ssSelections   (ssget "x" (list (cons 0 "POINT"))))
         (setq lstSelections  (selectionsettolist ssSelections))
         (setq lstOfPoints    (mapcar '(lambda (X)(vlax-get X "coordinates")) lstSelections))
         (setq lstOfPoints    (mapcar (quote (lambda (X)(mapcar '* (list 1 -1 1) X))) lstOfPoints));<- Mirrored about X-X
         (setq lstOfPoints    (mapcar (quote (lambda (X)(mapcar '+ (list 0 3000 0) X))) lstOfPoints));<- add 3000 to Y coordinate
         (setq lstOfPoints    (cons (list "X" "Y" "Z") lstOfPoints))
         (setq strCSVFullName (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv"))
    )
 (progn
  (while (vl-string-search " " strCSVFullName)(setq strCSVFullName (vl-string-subst "" " " strCSVFullName)))
  ;Startapp doesn't like spaces
  (ListToCSVFile strCSVFullName lstOfPoints ",")
  (startapp "C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE" strCSVFullName)
 )
)
)

;___________________________________________________________________________________________________________ 
;
; Function to convert a entity based selection set to a list.
;___________________________________________________________________________________________________________

(defun SelectionSetToList (ssSelections / entSelection intCount lstObjects objSelection )
(repeat (setq intCount (sslength ssSelections))
 (setq intCount (1- intCount))
 (setq entSelection (ssname ssSelections intCount))
 (setq objSelection (vlax-ename->vla-object entSelection))
 (setq lstObjects   (cons objSelection lstObjects))
)
(reverse lstObjects)
)

;___________________________________________________________________________________________________________
;
; Export a list of sublists of to a text file
;___________________________________________________________________________________________________________


(defun ListToCSVFile (strFilename lstOfSublists strChar / strText strText2 filData lstSublist)
(setq filData (open strFileName "w"))
(close filData)
(setq filData (open strFileName "w"))
(foreach lstSubList lstOfSublists 
 (setq strText (vl-princ-to-string (nth 0 lstSubList)))
 (if (and (= (type (cdr lstSublist)) 'LIST)
          (> (length lstSublist) 1)
     )
  (foreach strText2 (cdr lstSubList)
   (setq strText (strcat strText strChar (vl-princ-to-string strText2)))
  )
  (if (cdr lstSublist)
   (setq strText (strcat strText strChar (vl-princ-to-string (cdr lstSubList))))    
  )
 )
 (write-line strText filData)
)
(close filData)
(prin1)
)

(vl-load-com)

 

 

Thank you,

with best regards.

Error in lisp.JPG

Posted

Remove:

(while (vl-string-search " " strCSVFullName)(setq strCSVFullName (vl-string-subst "" " " strCSVFullName)))

And change:

(startapp "C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE" strCSVFullName)

to:

(startapp "C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE" (strcat "\"" strCSVFullName "\""))

Posted

 

Dear sir,

Thank you for fixing error.

 

Best Wishes.

  • 5 months later...
Posted
You're welcome!

 

 

Hello sir,

 

After long time i have tried your modified code. i have face some technical issues by excel output. actually i need mirror points to excel. but at excel showing un natural values. please find sample format of excel out image. kindly fix the error.

 

Best wishes.

Sample format.JPG

Mirror points export required.dwg

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...