最初由 colatree 发布
[B]請問在工具箱中是否有將4折或多折的多義線
取其中某一線段的起點與終點座標,即
用entsel取得pline及點對(可能是第2段折線)
然後用函數求得第2段折線的起點與終點
是否有這樣的函數
謝謝 [/B]
下面是工具箱 obj_polyline.lsp 中的一个通用函数,程序适合polyline和lwpolyline。

- ;|
- 用法:($XDLSP_PolyLine_getSegAt <多义线实体名> <测试点> <绘制标记>)
- 获得一个*POLYLINE线上指定一点处的“段”的信息。
- 对于直线段返回:(顶点索引 "kLine" 起点 终点)
- 对于弧线段返回:(顶点索引 "kArc" 起点 凸度 终点)
- 所有返回点在UCS下。
- |;
- (defun $XDLSP_PolyLine_getSegAt (e pt clr / cNa tf i nNums eTyl eSegData el
- tf1 tf2
- )
- (setq cNa (car (xdrx_Object_ClassName e)))
- (if (wcmatch cNa "*POLYLINE")
- (progn
- (setq tf t)
- (if (setq tf (= cNa "POLYLINE"))
- (setq tf (xdrx_polyline_ConvertFrom e)
- tf2 tf
- )
- (setq tf t)
- )
- (if tf
- (progn
- (setq nNums (xdrx_polyline_numVerts e)
- i -1
- )
- (setq tf1 t)
- (while (and
- tf1
- (< i nNums)
- )
- (if (xdrx_polyline_onSegAt e (setq i (1+ i))
- pt
- )
- (progn
- (setq eTyl (xdrx_polyline_segtype e i)
- eSegData (cond
- ((= "kLine" eTyl)
- (setq data1
- (xdrx_polyline_getLineSegAt e i)
- data2
- (xdrx_polyline_getWidthsAt e i)
- )
- (if (/= clr 0)
- (progn
- (apply
- 'command
- (cons ".pline" data1)
- )
- (command "")
- (if (= "POLYLINE" (car (xdrx_object_classname (entlast))))
- (xdrx_polyline_ConvertFrom (entlast))
- )
- (xdrx_polyline_setConstantWidth
- (entlast)
- (/
- (getvar "viewsize") 64
- )
- )
- (xdrx_entity_setcolor
- (entlast) 1
- )
- )
- )
- (append
- data1
- data2
- )
- )
- ((= "kArc") ; (xdrx_polyline_getArcSegAt e
- ; i)
- (list (xdrx_polyline_getpointat e i)
- (xdrx_polyline_getBulgeAt e i)
- (xdrx_polyline_getpointat e
- (1+ i)
- )
- )
- )
- )
- el (cons i (cons eTyl eSegData))
- tf1 nil
- )
- )
- )
- )
- )
- )
- (if tf2
- (xdrx_polyline->2dpolyline e)
- )
- )
- )
- el
- )
|