I'm slow today. Will this work?
Code:
(defun c:ExportProfile (/ AT:WriteToFile op:ExportProfile sFile)
;;; Write list to file
;;; #File - file to write list to (must be in form "c:\\File.txt")
;;; #ListToWrite - list to write to file
;;; #Overwrite - If T, will overwrite; nil to append
;;; Alan J. Thompson, 04.28.09
;;; https://forums.augi.com/showthread.php?117203-open-and-read-text-file&p=1059711&viewfull=1#post1059711
(defun AT:WriteToFile (#File #ListToWrite #Overwrite / #FileOpen)
(cond ((and (vl-consp #ListToWrite)
(setq #FileOpen (open #File
(if #Overwrite
"W"
"A"
) ;_ if
) ;_ open
) ;_ setq
) ;_ and
(foreach x #ListToWrite
(write-line (vl-princ-to-string x) #FileOpen)
) ;_ foreach
(close #FileOpen)
t
)
) ;_ cond
) ;_ defun
(defun op:ExportProfile ( oProfile / oPVIs lPVIs sData)
(if (setq oPVIs (vlax-get-property oProfile 'PVIs))
(vlax-for n oPVIs
(if
(and (not lPVIs) (vlax-property-available-p n 'CurveLength))
(exit)
)
(setq
sData (strcat (rtos (vlax-get-property n 'Station) 2 2)
" "
(rtos (vlax-get-property n 'Elevation) 2 2)
)
)
(if (vlax-property-available-p n 'CurveLength)
(setq
sData
(strcat sData
" "
(rtos (vlax-get-property n 'CurveLength) 2 2)
)
)
)
(setq lPVIs (append lPVIs (list sData)))
)
)
lPVIs
)
(if (and (setq oProfile (entsel "\nSelect profile: "))
(= (type oProfile) 'list)
(= (type (car oProfile)) 'ENAME)
(setq oProfile (car oProfile))
(setq oProfile (vlax-ename->vla-object oProfile))
(= (vla-get-objectName oProfile) "AeccDbVAlignment")
(= (vlax-get-property oProfile 'Type) 2)
(setq sName (vla-get-name oProfile))
(setq sFile (getfiled "Export Profile" (strcat (getvar 'dwgprefix) sName ".txt") "txt" 1))
(setq lPVIs (op:ExportProfile oProfile))
)
(AT:WriteToFile sFile lPVIs t)
)
)
I'm not going to document it, but it does need one more check on the last segment to verify it does not have a curve property. Also, the vertical curves, per the C3D documentation, are assumed to be parabolic.