这是一个通用示例。
- Sub Example_AddLine()
- [color="SeaGreen"] ' This example adds a line in model space[/color]
-
- Dim lineObj As AcadLine
- Dim startPoint() As Double
- Dim endPoint() As Double
- Dim TransPoint() As Double
- Dim TargetLayer As AcadLayer
-
- startPoint = ThisDrawing.Utility.GetPoint(, "Select Start Point: ")
- [color="SeaGreen"] 'point returned as WCS point. Needs temporary translation to UCS point[/color]
- TransPoint = ThisDrawing.Utility.TranslateCoordinates(startPoint, acWorld, acUCS, 0)
- [color="seagreen"]'That translated point can be used as reference for next point selection[/color]
- endPoint = ThisDrawing.Utility.GetPoint(TransPoint, "Select End Point: ")
-
- [color="seagreen"]' Create the line in model space with the WCS points[/color]
- Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
-
- Set TargetLayer = ThisDrawing.Layers.Add("LineLayer")
- [color="seagreen"]'Get reference to layer[/color]
- TargetLayer.color = acRed
- [color="seagreen"]'set line to that layer[/color]
- lineObj.Layer = "LineLayer"
-
- End Sub
|