最初由 giswater 发布
[B]多线段中可能只有折线,也会有圆弧,怎样能实现自动找出其中带圆弧的多线段,同时不改变他们的图层,颜色等本来的信息 [/B]
下面的函数在晓东工具箱环境下,参数是POLYLINE实体名和POLYLINE上的一个测试点和是否绘制标记CLR,NIL或者T。
该函数能把POLYLINE上,测试点下面的线或者弧线得到他们的起始,结束点等参数,如果函数参数CLR为T,直接画出测试点下面的线或者弧线。
你可以参考下。

- ;|
- 用法:($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
- )
|