put exsisting dimensions into a text file

Discussion in 'AutoCAD' started by Angie Peters, Jun 21, 2004.

  1. Angie Peters

    Angie Peters Guest

    I want to write a routine that will create a text file containing the dimension values on an existing drawing. Is this possible?
     
    Angie Peters, Jun 21, 2004
    #1
  2. Pseudo-Code

    getstring "File Name"
    if findfile FileName
    open FileName to write or append
    ssget dimensions
    if selection set
    entget dimension data
    if text dimension stored
    write-line dimension text
    else
    calculate dimension based on dimension type
    write-line text value
    endif
    endif
    close FILENAME
    endif
     
    Alan Henderson @ A'cad Solutions, Jun 21, 2004
    #2
  3. Angie Peters

    zeha Guest

    This is a example how to write dimensions to a file
    Not for radius or angulair dimensions

    ;;;The file is been written to C:\DimText.txt
    ;;;There is no test for the file exist (overwriten each time used.)

    ;;;Subfunction L_cos (length angle distance pn1 pn2)

    (defun l_cos (pn1 pn2 ho)
    (* (cos (- ho (angle pn1 pn2)))(distance pn1 pn2))
    )
    (defun c:WriteDim (/ ss)
    (prompt "\nPick dimension entity(s): ")
    (if (and (setq ss (ssget '((0 . "DIMENSION"))))
    (setq filep (open "c:\\DimText.txt" "w")))
    (progn
    (setq i 0)
    (while (< i (sslength ss))
    (setq elist (entget (ssname ss i)) i (1+ i)
    flag (rem (cdr (assoc 70 elist)) 32)
    dimta (cdr (assoc 1 elist))
    ldim (cond ((= flag 0)(l_cos (cdr (assoc 13 elist))(cdr (assoc 14 elist))(cdr (assoc 50 elist))))
    ((= flag 1)(distance (cdr (assoc 13 elist))(cdr (assoc 14 elist)))))

    )
    (cond ((and ldim (= dimta ""))(write-line (rtos ldim 2 0) filep))
    ((/= dimta "")(write-line dimta filep))
    )
    )
    (close filep)
    )
    )
    )

    Good luck

    Harrie
     
    zeha, Jun 22, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.