Jump to content

Lisp to import coords and code from txt/xls file...


Recommended Posts

Posted

Hello everyone!!

 

I need a LISp that imports X,Y,Z,and CODE or some other attributes from txt or xls/csv file, and puts it to new layer separately like this:

 

POINT with coodrinates (X;Y;Z) should be layer TOCKA (*croatian language*)

HEIHGT (Z coord) should be layer VISINA

NUMBER OF POINT should be layer BROJ TOCKE

CODE should be layer KOD

and if some other attributes exist than can become layer OSTALO

 

I saw a lot of lisps that do part of this but didnt find any to puts it in different layers, so if anybody knows how to do it...This would be good for geodesy and many geodesiests in the world, because this is my job also....THX in advance..:roll:

  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    32

  • goldy2000

    27

  • tagkelas

    5

  • stevesfr

    3

Posted

I've got one that will read coordinates and populate the drawing with blocks of your choosing. It will also populate the attributes of the block in the order they appear in your excel/text file.

 

Example:

 

X coord y coord attribute1 attribute 2

 

Do you want me to send it or is it not compatible with your designs?

Posted

I have something similiar, it puts every coord in its axis, you can send it so I can try it, thx man!!

Posted

This can be done -

Just a few things to ask though:

Are the POINT NUMBER, Z COORD and CODE all attributes? Or are some just text?

Also, if they are all attributes, are they contained in a block that you have?

Posted

new LAYER: POINT --> TOCKA (these are croatian words)

Z HEIGHT--> VISINA

CODE --> KOD

POINT NUMBER--> BROJ TOCKE

 

Yep, these 3 are the only atrributes.

 

example:

Point number Y X Z code

 

1 100.00 20.11 2.45 road

 

POINT(TOCKA) is Y,X,Z coord and in dwg file is only dot.

CODE(KOD) is text but it is situated at point position

POINT NUMBER(BROJ TOCKE) is similiar like CODE

HEIGHT Z is text that shows number, in this case 2.45, and situated near POINT position

 

They aren't block, they are only text and point(dot in this case)...little clearly?? My english is not so great so I can't explain the best as I would do it

Posted

Can I send you some example dwg file??

Posted
new LAYER: POINT --> TOCKA (these are croatian words)

Z HEIGHT--> VISINA

CODE --> KOD

POINT NUMBER--> BROJ TOCKE

 

Yep, these 3 are the only atrributes.

 

example:

Point number Y X Z code

 

1 100.00 20.11 2.45 road

 

POINT(TOCKA) is Y,X,Z coord and in dwg file is only dot.

CODE(KOD) is text but it is situated at point position

POINT NUMBER(BROJ TOCKE) is similiar like CODE

HEIGHT Z is text that shows number, in this case 2.45, and situated near POINT position

 

They aren't block, they are only text and point(dot in this case)...little clearly?? My english is not so great so I can't explain the best as I would do it

 

Ah, ok - I understand, :)

Posted

I have something interesting for you (txt, csv, xls - trebam tvoj mail).

Not lsp but dvb.

Posted

dmikicic1981@yahoo.com

 

dvb?? something like lisp command?? I read something about dvb..but..never mind I'll figure it out, Goran from Croatia??

Posted

Try this Goldy :)

 

(defun c:goldy (/ doc spc file nl lst pt)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true) ; Vport
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (or (tblsearch "LAYER" "TOCKA")
   (vla-add (vla-get-layers doc) "TOCKA"))
 (if (setq file (getfiled "Select Text File"
                       (if *load$file* *load$file* "") "txt" )
   (progn
     ;(vlp file)
     (setq *load$file* file file (open file "r"))
     (while (setq nl (read-line file))
       (setq lst (cons (StrBrk nl 32) lst)))
     (close file)
     (foreach line lst
       (setq pt
         (mapcar 'distof
           (list (caddr line) (cadr line) (cadddr line))))
       (vla-put-layer
         (vla-AddPoint spc (vlax-3D-point pt)) "TOCKA")
       (Make_Text pt (last line) 0.0 "KOD" 1 2)
       (Make_Text pt (car line) 0.0 "BROJ TOCKE" 1 0)
       (Make_Text pt (cadddr line) 0.0 "VISINA" 1 3)))
   (princ "\n<!> No File Selected <!>"))
 (princ))


(defun StrBrk (str chrc / pos lst)
 (while (setq pos (vl-string-position chrc str))
   (setq lst (cons (substr str 1 pos) lst)
         str (substr str (+ pos 2))))
 (reverse (cons str lst)))

(defun Make_Text  (pt val rot lay |72 |73)
 (entmake
   (list
     (cons 0 "TEXT")
     (cons 8  lay)
     (cons 10 pt)
     (cons 40 (getvar "TEXTSIZE"))
     (cons 1  val)
     (cons 50 rot)
     (cons 7  (getvar "TEXTSTYLE"))
     (cons 71 0)
     (cons 72 |72)
     (cons 73 |73)
     (cons 11 pt))))


Posted

Hellloo Lee Mac, it writes me this in command line when start lisp(when pick .txt file):

 

; error: no function definition: VLP

 

Hmmm, maybe it is complicated, dont waste your time man

Posted

Sorry dude, thats just my sub-function that I include for testing (forgot to take it out) - code updated, please try it again :)

Posted
Hmmm, maybe it is complicated, dont waste your time man

 

Nothing is too complicated :P If you can imagine it :lol:

Posted

Heyy, ok I will try, can you send me lisp? or insert here?

Posted
Heyy, ok I will try, can you send me lisp? or insert here?

 

I have updated the previous code that I posted :)

Posted

; error: bad argument type: numberp: nil

 

It says this...

 

Maybe is in .txt file problem?

 

It looks like this:

VAR_1 6500000.000 5410000.000 122.00 STRANG

... _2 ...............................................TEREN

...

...

Posted

It seems to work for me :unsure:

 

Does the file selection dialog appear?

Posted

No, dialog doesn't appear, maybe is problem in .txt file, is your file like mine?? Dialog when selecting txt file appears but after selecting file it shows me this ; error: bad argument type: numberp: nil

Posted

I just copied the text that you just posted and saved it in a Notepad file to test it... - didn't have a problem with it :huh:

Posted

hmmm...cannot figure what is wrong, just took your lisp and put it in notepad and upload application..totaly strange, I see that you use ACAD 2010, maybe this is a problem??

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