Hey guys, I was wondering if there was a way (lsp/dcl) to import a csv which contains the following columns:
PtID X Y Z Code
or
PtID X Y Z Code Des
@Anonymous wrote:
Hey guys, I was wondering if there was a way (lsp/dcl) to import a csv which contains the following columns:
PtID X Y Z Code
or
PtID X Y Z Code Des
Import into what? a block with attribute? or a TEXT/MTEXT entity?
Is it possible to import the csv into autocad as nodes? I would like the data from the csv PtID and code retained within the node.
@Anonymous wrote:
Is it possible to import the csv into autocad as nodes? I would like the data from the csv PtID and code retained within the node.
Nodes as in POINT entitiy? So basically a BLOCK with a POINT entity and Attributes [invisible or otherwise] for the data [PtID and code] correct?
Show us a sample of the CSV data. and also how it will look like in cad
Yes a point entity. I could live if the last column (Description) wasnt included. I just need to be able to import surveyed points from a csv file and retain the point ID and code in order to make snense of the data. I need to be able to inquire the points and see the point number and code when i use the ID command. Please see atached image for reference to the csv format.
@Anonymous wrote:
Yes a point entity. I could live if the last column (Description) wasnt included. I just need to be able to import surveyed points from a csv file and retain the point ID and code in order to make snense of the data. I need to be able to inquire the points and see the point number and code when i use the ID command. Please see atached image for reference to the csv format.
Ok. now to "retain" the point ID you need a placeholder for that data correct? do you prefer attributes or plain text? But like i said. post a sample drawing of the desired result [Drawing file please and NOT PNG]
Is it possible to retain the Pt Id and code? I have imported a csv into a third party cad program and then exported top dxf. The attached .dwg is the result.
@Anonymous wrote:
Is it possible to retain the Pt Id and code? I have imported a csv into a third party cad program and then exported top dxf. The attached .dwg is the result.
Why of course, theres a couple of ways to do that. invisible attributes or XDATA, for now we will stick with invisible attributes.. hang on i will write a quick one for you. [one with just placing the points and no ID ]....
EDIT: I'm not sure if the CAD software you are using can recognize attributes. Can you verify this?
This one use point entity [no attributes]
(defun c:rcsv (/ _delFinder ss e a data b attrvalues) ;;; pBe 21July2014 ;;; (defun _delFinder (str md / d l str) (while (setq d (vl-string-position md str nil T)) (setq l (cons (substr str (+ 2 d)) l) str (substr str 1 d) ) ) (cons str l) ) (if (setq data nil file (getfiled "Select CSV file" (getvar 'dwgprefix) "CSV" 16)) (progn (setq of (open file "r")) (while (setq a (read-line of)) (setq data (cons (_delFinder a 44) data)) ) (close of) (foreach itm (cdr (reverse data)) (entmakex (list (cons 0 "POINT") (cons 10 (mapcar 'distof (list (cadr itm) (caddr itm) (cadddr itm))) ) (cons 8 (nth 4 itm)) ) ) ) ) ) (princ) )
And this using a block with attributes [invisible attributes]
(defun c:rcsv (/ _delFinder ss file of a data atblk) ;;; pBe 21July2014 ;;; (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (defun _delFinder (str md / d l str) (while (setq d (vl-string-position md str nil T)) (setq l (cons (substr str (+ 2 d)) l) str (substr str 1 d) ) ) (cons str l) ) (if (and (or (tblsearch "block" (setq bn "CCAD_POINT")) (setq bn (findfile "CCAD_POINT.dwg")) ) (setq data nil file (getfiled "Select CSV file" (getvar 'dwgprefix) "CSV" 16) ) ) (progn (setq of (open file "r")) (while (setq a (read-line of)) (setq data (cons (_delFinder a 44) data)) ) (close of) (foreach itm (cdr (reverse data)) (setq atblk (vlax-invoke (vlax-get (vla-get-ActiveLayout adoc) 'Block) 'InsertBlock (mapcar 'distof (list (cadr itm) (caddr itm) (cadddr itm))) bn 1 1 1 0) ) (mapcar '(lambda (av va) (vla-put-textstring va av)) (list (car itm) (nth 4 itm)) (vlax-invoke atblk 'Getattributes)) ) ) (princ (cond ((null bn) "\n<<Block \"CCAD_POINT\" Not Found>>") ((null file) "\n<<Point file Not Found>>") )) ) (princ) )(vl-load-com)
HTH
An old post but a relevant one for me, I have run the script with blocks however no block have been inserted that I can see. Any suggestions ?
Can't find what you're looking for? Ask the community or share your knowledge.