不好意思,昨天没有贴全代码. Sub test_of_SetBulge(ByVal l As Double, ByVal w As Double) '2*l为矩形长度,2*W为宽度 Dim acadapp As Object Dim insert_point As Variant Dim insert_point_x As Double Dim insert_point_y As Double Dim poly_line As Object Dim p(9) As Double Set acadapp = GetObject(, "autocad.application") insert_point = acadapp.ActiveDocument.Utility.GetPoint(, vbCr + "请在屏幕上指定插入点:") '矩形对角线交叉点 insert_point_x = insert_point(0) insert_point_y = insert_point(1) p(0) = insert_point_x + l - w: p(1) = insert_point_y + w p(2) = insert_point_x - l + w: p(3) = insert_point_y + w p(4) = insert_point_x - l + w: p(5) = insert_point_y - w p(6) = insert_point_x + l - w: p(7) = insert_point_y - w p(8) = insert_point_x + l - w: p(9) = insert_point_y + w Set poly_line = acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(p) poly_line.SetBulge 1, 1 poly_line.SetBulge 3, 1 acadapp.Update Set acadapp = Nothing End Sub Private Sub Command1_Click() test_of_SetBulge 100, 40 End Sub |