Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Need Code for Exporting Point insertions to Excel

  1. #11
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: Need Code for Exporting Point insertions to Excel

    You will need to cut and paste this code...

    For some reason it will not let me attach the file.

    Peter

    Code:
    (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)
    Last edited by peter; 2017-03-15 at 03:23 AM.
    AutomateCAD

  2. #12
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Need Code for Exporting Point insertions to Excel

    Dear sir,
    thank you for providing final code. i have tried final code. and results are varying. x coordinates values are ok, but y coordinate values are multiplied by "1000", showed like a "3000", "2994" etc. please find sample drawing and kindly fix.

    Thanking you for great contribution,
    Best regards.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by prasadcivil; 2017-03-14 at 10:13 AM.

  3. #13
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: Need Code for Exporting Point insertions to Excel

    In the thread you mentioned you wanted to mirror the points across the X-X axis and move them up 3000.

    I commented out the mirror and the move parts above.

    You need to work on understanding the code and making modifications to it per your needs.

    Peter
    AutomateCAD

  4. #14
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Need Code for Exporting Point insertions to Excel

    Dear sir,

    i actually mentioned in that post is units are "mm", not 3000. and i understood your code and required modifications. after modification your code is working as per my requirements. thank you for preparing.

    Best regards.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. .Net code to import polylines from excel
    By gisvision in forum Dot Net API
    Replies: 15
    Last Post: 2023-06-05, 02:28 PM
  2. Replies: 5
    Last Post: 2013-10-16, 05:39 PM
  3. AU 2005 VBA with Excel Sample Code
    By wpeacock in forum VBA/COM Interop
    Replies: 2
    Last Post: 2007-03-12, 10:34 AM
  4. How to Code an Excel Autosave
    By PellaCAD in forum VBA/COM Interop
    Replies: 1
    Last Post: 2006-04-19, 05:38 PM
  5. point code descriptions
    By jswick in forum AutoLISP
    Replies: 1
    Last Post: 2005-08-30, 02:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •