Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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

Posted

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

Posted

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

Posted

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

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