- Option Explicit
- Private Sub CommandButton1_Click()
- Dim ObjBlock As AcadBlock
- Dim ObjLine As AcadLine
- Dim ObjLine1 As AcadLine
- Dim ObjLWPLine As AcadLWPolyline
- Dim InsertPt(0 To 2) As Double
- Dim PickPt As Variant
- Dim pt1(0 To 2) As Double
- Dim pt2(0 To 2) As Double
- Dim pt3(0 To 2) As Double
- Dim pt4(0 To 2) As Double
- Dim pt5(0 To 2) As Double
- Dim Points(0 To 3) As Double
- Dim x As Double
- Dim y As Double
- frmMain.Hide
- PickPt = ThisDrawing.Utility.GetPoint(, "获取第一点")
- x = PickPt(0): y = PickPt(1)
- InsertPt(0) = x: InsertPt(1) = y: InsertPt(2) = 0
- pt1(0) = x: pt1(1) = y: pt1(2) = 0
- pt2(0) = x + 4: pt2(1) = y: pt2(2) = 0
- pt3(0) = x: pt3(1) = y - 5: pt3(2) = 0
- pt4(0) = x: pt4(1) = y + 5: pt4(2) = 0
- pt5(0) = x + 6: pt5(1) = y: pt5(2) = 0
- Points(0) = x + 6: Points(1) = y
- Points(2) = x + 4: Points(3) = y
- Set ObjBlock = ThisDrawing.Blocks.Add(InsertPt, "产状图块")
- Set ObjLine = ObjBlock.AddLine(pt1, pt2)
- Set ObjLine1 = ObjBlock.AddLine(pt3, pt4)
- Set ObjLWPLine = ObjBlock.AddLightWeightPolyline(Points)
- ObjLWPLine.SetWidth 0, 0, 1.5
- ObjLine.Lineweight = acLnWt030
- ObjLine1.Lineweight = acLnWt030
- ObjLine.color = acRed
- ObjLine1.color = acRed
- ObjLWPLine.color = acRed
- Dim BlockInsertRef As AcadBlockReference
- Set BlockInsertRef = ThisDrawing.ModelSpace.InsertBlock(InsertPt, "产状图块", 1, 1, 1, 0)
- frmMain.Show
- End Sub
|