+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21
  1. #1
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default a couple of point coordinates into a text file

    Registered forum members do not see this ad.

    Hi i.m using cad 2006.
    i have a drawing that they use to set out pile into the fild with a totalstation
    now i want to export the coordinates of de pile on the drawing to the total station with a text file. ( it's not one pile but many pile's )
    can some one help me to do this with maybe a lisp or some command...

    thanks...

  2. #2
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default

    can some one help with this one... thanks....

  3. #3
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    XP Pro
    Computer:
    Dell
    CPU:
    Intel Xeon 2.13GHz
    RAM:
    2GB
    Graphics:
    NVIDA Quadro FX 580
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,125

    Default

    a little more detail please, I don't quite understand your problem.

    Are the piles AutoCAD blocks?
    What information are you wanting into the text file?
    X,Y,Z for each pile?
    Are you going to export information from every pile or select them from the screen?

    If the problem is as I think, I would make a block then using a selection set (VBA as my languge of choice but equally easy from LISP) I would export X,Y,Z for each item in the selection set to a text file. All relatively simple but I don't have AutoCAD at home so could only "hint" at how to do it today.
    "That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson

    Dave

  4. #4
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default

    HOi.. the piles ( they are blocks ) are marked with a cross where i can select the centre point of it.. and there i want the coord x,y, into a txt of excel file.

    there are more than 20 piles on the drawing so i want them all in to the file

    maybe there is a lisp routine for it.
    so i can select the centre point of many points and he will put the x,y coords into the file.

    i hope i have explaned it better...

    thanks

  5. #5
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    XP Pro
    Computer:
    Dell
    CPU:
    Intel Xeon 2.13GHz
    RAM:
    2GB
    Graphics:
    NVIDA Quadro FX 580
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,125

    Default

    I think so

    As I said earlier I can't write the code at home but my code would be something like this (psudo code)

    Code:
    make a selection set of all blocks named "PILE"
    for each block in selection set
       get insertion point
       write insertion point to "myFile.txt"
       loop
    In other words, it looks relatively simple. If nobody does it for you today I'll give it a try tomorrow at work.
    "That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson

    Dave

  6. #6
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Try this. X and Y sorted coordinates of blocks insertion points writes to Excel file (in current UCS). You can preliminary select all blocks with name "PILE" by QSELECT.

    Code:
    (defun c:ptex(/ BLLIST BLSET CURCELL CURID CURLST
    	      CURORD CURROW CURVAL EXAPP EXFILE
    	      EXPATH EXSHEET EXSHEETS EXWORKBOOK
    	      OUTLIST OUTLST UTILOBJ SORTLST)
      
      (vl-load-com)
      
      (if
        (not
          (setq blSet(ssget "_I" '((0 . "INSERT")))))
          (progn
    	(princ "\n*** Select blocks ***")
    	(setq blSet(ssget '((0 . "INSERT"))))
    	); end progn
        ); end if
      (if blSet
        (progn
          (setq blList(mapcar 'vlax-ename->vla-object 
                        (vl-remove-if 'listp 
                         (mapcar 'cadr(ssnamex blSet))))
    	    outList '()
    	    sortLst '()
    	    utilObj
    	     (vla-get-Utility
    	       (vla-get-ActiveDocument
    		 (vlax-get-acad-object)))
    	    ); end setq
    	    (foreach itm blList
    	      (setq curLst
    		     (vlax-safearray->list
    		       (vlax-variant-value
    			 (vla-TranslateCoordinates utilObj
    		           (vla-get-InsertionPoint itm)
    			     acWorld acUCS :vlax-false)))
    		    sortLst(append sortLst(list curLst))
    		    ); end setq
    	      ); end foreach
    		(setq sortLst(vl-sort sortLst
    				    (function
    				      (lambda(e1 e2)
    					&#40;< &#40;car e1&#41; &#40;car e2&#41;&#41;&#41;&#41;&#41;
                        sortLst&#40;vl-sort sortLst
    				    &#40;function
    				      &#40;lambda&#40;e1 e2&#41;
    					&#40;and
    					  &#40;equal
    					    &#40;car e1&#41;&#40;car e2&#41;&#41;
    					  &#40;<&#40;cadr e1&#41;&#40;cadr e2&#41;&#41;&#41;&#41;&#41;&#41;
    		      &#41;; end setq
             &#40;foreach itm sortLst
    		&#40;setq curOrd
    		     &#40;strcat&#40;rtos&#40;car itm&#41;&#41;", "&#40;rtos&#40;cadr itm&#41;&#41;&#41;
    		    outList&#40;append outList&#40;list curOrd&#41;&#41;
    		    &#41;; end setq
    	      &#41;; end foreach
    	   &#40;if &#40;setq  exPath&#40;getfiled "Save Text File As"
               &#40;strcat &#40;getvar "dwgprefix"&#41;&#40;substr &#40;getvar "dwgname"&#41; 1
    		&#40;- &#40;strlen &#40;getvar "dwgname"&#41;&#41; 4&#41;&#41; ".xls"&#41;"xls" 33&#41;; end getfiled
                &#41;; end setq
    	     &#40;progn
    	&#40;setq exApp&#40;vlax-create-object "Excel.Application"&#41;&#41;
    	&#40;if&#40;null exApp&#41;
    	  &#40;progn
    	    &#40;alert "Error. Can't start MS Excel."&#41;
    	    &#40;quit&#41;
    	    &#41;; end progn
    	    &#41;; end if
    	 &#40;setq exWorkbook
    	           &#40;vlax-get-property exApp "Workbooks"&#41;
    	       exFile
    	           &#40;vlax-invoke-method exWorkbook "Add"&#41;
    	       exSheets
    	           &#40;vlax-get-property exFile "Worksheets"&#41; 
                   exSheet
    	           &#40;vlax-get-property exSheets "Item" "Sheet1"&#41;
    	       curRow 1
    	&#41;; end setq
    	  &#40;repeat&#40;length outList&#41;
    	    &#40;setq curId&#40;strcat "A"&#40;itoa curRow&#41;&#41;
    		  curCell&#40;vlax-variant-value
    		         &#40;vlax-invoke-method exSheet "Evaluate" curId&#41;&#41;
    		  curVal&#40;nth&#40;1- curRow&#41; outList&#41;
    		  &#41;; end setq
    		  &#40;vlax-put-property curCell  "Formula" curVal&#41;
    	    &#40;vlax-release-object curCell&#41;
    	    &#40;setq curRow&#40;1+ curRow&#41;&#41;
    	    &#41;; end repeat
    	  &#40;vlax-invoke-method exFile "SaveAs" exPath nil nil nil nil nil nil&#41;
    	  &#40;vlax-invoke-method exFile "Close" nil&#41;
    	  &#40;vlax-invoke-method exApp "Quit"&#41;
        &#40;mapcar&#40;function&#40;lambda&#40;x&#41;
    	       &#40;if
    		 &#40;and x&#40;not&#40;vlax-object-released-p x&#41;&#41;&#41;
    		 &#40;vlax-release-object x&#41;
    		 &#41;
    	       &#41;&#41;
        &#40;list curCell exSheet exSheets exFile exWorkbook exApp&#41;
        &#41;
        &#40;setq curCell nil
              exSheet nil
              exSheets nil
              exFile nil
    	  exWorkbook nil
    	  exApp nil&#41;; end setq
        &#40;gc&#41;
    	&#40;princ&#40;strcat"\n*** The file was successfully saved in&#58; " exPath&#41;&#41; 
    	&#41;; end progn
    	     &#40;princ "\n*** Excel file was not created! *** "&#41;
    	     &#41;; end if
        &#41;; end progn
        &#40;princ "\n*** Nothing blocks selected! ***"&#41;
      &#41;; end if
          &#40;princ&#41;
          &#41;; end of PTEX
    
    &#40;princ "\nType PTEX to run."&#41;

  7. #7
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default

    Thanks for the help ..i'am trying it...

    it look all abacadabra for me...

    can i get the coord of the piles only that i selected or will he take it form all the piles

    thanks...

  8. #8
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default

    it looks great... i have tryed it...
    and i get a error message...

    Command: _appload ptex.lsp successfully loaded.
    Command:
    Type PTEX to run.
    Command:
    Command: PTEX
    *** Select blocks ***
    Select objects: 1 found
    Select objects: 1 found, 2 total
    Select objects: 1 found, 3 total
    Select objects: 1 found, 4 total
    Select objects: 1 found, 5 total
    Select objects: 1 found, 6 total
    Select objects: 1 found, 7 total
    Select objects:
    ; error: Automation Error. Description was not provided.
    Command:


    Maybe you now what i did wrong ...

    thanks

    P.S. if you have written this specialie for me.....than it's fantastic...

  9. #9
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    What AutoCAD and MS Office version you use? Obviously problem in version MS Office... Try now simple 'on text screen' version of the program. It works? If it is necessary to add sorting of coordinates and record in *.txt a file I shall make it.

    Code:
    &#40;defun c&#58;ptx&#40;/&#41;
    	    &#40;mapcar '&#40;lambda&#40;x&#41;&#40;princ
    	     &#40;strcat "\n"&#40;rtos&#40;car x&#41;&#41;","&#40;rtos&#40;cadr x&#41;&#41;&#41;&#41;&#41;
    	     &#40;mapcar 'cdr
    	      &#40;mapcar '&#40;lambda&#40;x&#41;&#40;assoc 10 x&#41;&#41;
    	       &#40;mapcar 'entget
    	        &#40;vl-remove-if 'listp 
                         &#40;mapcar 'cadr&#40;ssnamex
    			&#40;ssget '&#40;&#40;0 . "INSERT"&#41;&#41;&#41;&#41;&#41;&#41;&#41;&#41;&#41;&#41;
          &#40;textscr&#41;
      &#40;princ&#41;
      &#41;; end  of c&#58;ptx

  10. #10
    Junior Member
    Using
    not specified
    Join Date
    Jun 2005
    Posts
    17

    Default

    Registered forum members do not see this ad.

    i'm using autocad 2006 an office excel 2003...

    It is not nessasary to sort... because the order that i select the blocks it the right order...


    But when i get the error message... he hasn't written the file to harddisk...

    thanks

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