我相信这就是你想要的:
- [color=magenta](defun TrimPline( myline trim_dist[/color]
- [color=magenta] / start_point trim_point edpt el_length trim_point2 end_point )[/color]
- ; First Break Point Sets
- (setq start_point (vlax-curve-getPointAtDist [color=red]myline[/color] 0))
- (setq trim_point (vlax-curve-getPointAtDist [color=red]myline[/color] trim_dist))
- ; First Break
- (command "._break" myline "_non" (trans start_point 0 1) "_non" (trans trim_point 0 1))
- ; Second Break Point Sets
- (setq edpt (vlax-curve-getendparam myline))
- (setq el_length (vlax-curve-getDistAtParam myline edpt)) ; length of element
- (setq trim_point2 (vlax-curve-getPointAtDist myline (- el_length trim_dist)))
- (setq end_point (vlax-curve-getPointAtDist myline el_length))
- ; Second Break
- (command "._break" myline "_non" (trans end_point 0 1) "_non" (trans trim_point2 0 1))
- ; Result
- [color=red] myline[/color]
- [color=magenta])[/color]
- [color=magenta](while (setq ssetPline (ssget "_:S" '((0 . "LWPOLYLINE"))))[/color]
- [color=magenta] (TrimPline (ssname ssetPline 0) 50.0)[/color]
- [color=magenta])[/color]
请注意,我对您的代码做了一些其他更正;您还需要添加一些验证,以使修剪尺寸不超过多段线的长度。 |