Jump to content
dalivore

Autolisp Help

Recommended Posts

dalivore

Does anyone know how to create a lisp that will export a csv file with object data and coordinates?

 

Example;

 

od field 1, od field 2,etc... x1,y1,z1,x2,y2,z2,etc....

 

Ideally it should be able to report all object data fields irregardless of the number. And it should report all xyz coordinates of polylines.

 

I would also need a lisp to import csv files from the above format.

 

If your curious this is all in an attempt to solve the 4 coordinate limits that map3d puts on exporting shape files... If someone has an alternate solution to that, I'm all ears!

 

Dalivore

Share this post


Link to post
Share on other sites
irneb

Not sure if there's already one of these somewhere. I know there's a lot of CSV export & import stuff around, but if they're specific to C3D/Map entity data I definitely don't know.

Share this post


Link to post
Share on other sites
BIGAL

An old solution its called a DXF file contains all object data and co-ords and its simple text file !

Share this post


Link to post
Share on other sites
Commandobill

I have something buried in the archives... let me find it. It ges rather hard as I would always name my code something random when I started...

Share this post


Link to post
Share on other sites
Commandobill

Also, If you have an example dwg I could test it with... that would be superb.

Share this post


Link to post
Share on other sites
Commandobill

Not perfect, but...

 

(defun c:objectDataExtract(/ coordslist count ent f fieldnames fieldstring path ss ssents strcatlst tablelist x z)
 (vl-load-com)
 (if (and (setq path (getfiled "Specify .CSV file name:"
   (getvar 'dwgprefix)
   "csv"
   1
   )
  )
   
   (setq ss (ssget "x")); SELECT EVERYTHING
   (setq ssEnts (vl-remove-if-not 'ade_odgettables (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))));Filter out only that which has a table attached to it
       (progn
     (setq f (open path "w"))
     (foreach ent ssents
(setq tablelist (ade_odgettables ent))
(setq count 0)
(repeat (length tablelist)
  (foreach def (cdr (assoc "Columns" (ade_odtabledefn (nth count tablelist))))
    (if (not (member (cdr (assoc "ColName" def)) fieldnames))
      (setq fieldnames (cons (cdr (assoc "ColName" def)) fieldnames))
      )
    )
  
  )


(setq strcatlst
       (apply 'strcat (mapcar '(lambda (x)
     (strcat x ": " (If (/= (type (setq fieldstring (ade_odgetfield ent (ade_odgettables ent) x 0))) 'STR)
        (rtos fieldstring 2 2)
        fieldstring) ",")) fieldnames)))

(setq coordsList (apply 'strcat (mapcar '(lambda (z) (strcat (rtos z 2) ",")) (vlax-get (vlax-ename->vla-object ent) 'Coordinates))))
(write-line (strcat strcatlst coordsList) f)

)
     (setq f (close f))
)))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×