兰州人 发表于 2008-11-27 16:42:00

LinetypeScale应用一例

<p>在一张图上的中心线,有的长,有的短,如果LinetypeScale都用1的话,有的中心线间距拉的开,有的就成为一条直线。</p><p>Sub lsls()<br/>&nbsp; Dim pt1, pt2<br/>&nbsp; Dim sSet As AcadSelectionSet<br/>&nbsp; pt1 = ThisDrawing.Utility.GetPoint(, "Input First Point")<br/>&nbsp; pt2 = ThisDrawing.Utility.GetCorner(pt1, "Input First Point")<br/>&nbsp; Set sSet = CreateSelectionSetCrossingText(pt1, pt2)<br/>&nbsp; Dim objText As AcadText<br/>&nbsp; Dim objLine As AcadLine<br/>&nbsp; For ii = 0 To sSet.Count - 1<br/>&nbsp;&nbsp;&nbsp; Set objLine = sSet.Item(ii)<br/>&nbsp;&nbsp;&nbsp; With objLine<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.Print .Length</p><p>通过判断长度,来设置LinetypeScale的值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case .Length<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case Is &lt;= 5<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .LinetypeScale = 0.1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case Is &lt;= 10<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .LinetypeScale = 0.2<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case Is &gt; 50<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .LinetypeScale = 0.8<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select<br/>&nbsp;&nbsp;&nbsp; End With<br/>&nbsp; Next ii<br/>End Sub</p><p>Function CreateSelectionSetCrossingText(pt1 As Variant, pt2 As Variant) As AcadSelectionSet<br/>&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp; Dim sSet As AcadSelectionSet<br/>&nbsp;&nbsp; 'Dim SSet As AcadSelectionSet<br/>&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("SelectEntity")) Then<br/>&nbsp;&nbsp;&nbsp;&nbsp; Set sSet = ThisDrawing.SelectionSets.Item("SelectEntity")<br/>&nbsp;&nbsp;&nbsp;&nbsp; sSet.Delete<br/>&nbsp;&nbsp; End If<br/>&nbsp;&nbsp; Set sSet = ThisDrawing.SelectionSets.Add("SelectEntity")<br/>&nbsp;&nbsp; Dim gpCode(0) As Integer<br/>&nbsp;&nbsp; Dim dataValue(0) As Variant<br/>&nbsp;&nbsp; gpCode(0) = 0<br/>&nbsp;&nbsp; dataValue(0) = "Line"<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; sSet.Select acSelectionSetCrossing, pt1, pt2, gpCode, dataValue</p><p>&nbsp;&nbsp; Set CreateSelectionSetCrossingText = sSet</p><p>End Function<br/></p>
页: [1]
查看完整版本: LinetypeScale应用一例