bp (dxfeg 10 sectline) ep (dxfeg 11 sectline);get section line endpoints, assuming an ordinary line entity for section line
;better project these to xy plane, so....
sectionintpoints nil;make a place to store all intersections between contours and this particular section line
)
(princ "\nChoose contours to sample (contours that the section line passes thru),") (setq pldata
(getcontourdata
(ssname sscontours i
));get elevation and 2d points elev
(car pldata
);retrieve elevation plis
(cdr pldata
);retrieve 2d point information (x and y coordinates of contour) thiscountourintpoints nil;make a place to store intersection points for this particular contour
backcountourpoint
(car plis
);store first vertex of polyline for intersection test purposes j 0;initialize contour vertex counter
)
(setq frontcontourpoint
(nth j plis
)) (cond ((null (setq ip
(inters backcountourpoint frontcontourpoint bp ep
))) nil);no intersection (t;intersection found
(setq thiscountourintpoints
;add to the list );setq
);t
);cond
(setq backcountourpoint frontcontourpoint
);move up the contour....... (setq j
(1+ j
));....and increment counter );while j
;sort by horizontal distance from bp
(setq sectionintpoints
(append thiscountourintpoints sectionintpoints
)) );while i
;now the list must be sorted by horizontal distance from bp
(setq sortedsectionintpoints
)
;draw section
lastpoint
(car sortedsectionintpoints
) cdrlis
(cdr sortedsectionintpoints
) )
(+ total_distance
)
)
;restore user's snap settings
);defun
;..............utility....................................................
;..................................................................
(defun getcontourdata
(e
/ mlis
);return a list whose first element is elevation; rest is 2d points follow ((= "LWPOLYLINE" (dxfeg
0 e
))(setq mlis
(lwpolyhan e
))) ((= "POLYLINE" (dxfeg
0 e
))(setq mlis
(polyhan e
))) )
mlis
)
(defun polyhan
(e
/ plis pl p
);this is for handing 3dpolylines, and it assumes the 3dpoly's vertices all have the same elevation (/= "SEQEND" (dxf 0 eg))
)
)
(setq plis
(if (= 1 (logand 1 (dxfeg
70 pl
)));if pline is closed, tack a copy of the last vertext onto the front; reverse order either way ;then
;else
)
)
)
(defun lwpolyhan
(e
/ eg elev datalis plis
) (setq eg
(entget e
) datalis eg plis
nil elev
(dxfeg
38 e
)) )
)
(setq plis
(if (= 1 (logand 1 (dxfeg
70 e
)));if pline is closed, tack a copy of the last vertext onto the front; reverse order either way ;then
;else
)
)
)