[VBA]求助:sendcommand 创建直线出现一些问题
我用 sendcommand 创建直线出现一些问题,请求各位大哥指点,程序如下Sub myl()<BR> Dim ptpick As Variant<BR> Dim x As Double<BR> Dim y As Double<BR> <BR> Dim x1 As Double<BR> Dim y1 As Double<BR> <BR> ptpick = ThisDrawing.Utility.GetPoint(, "请选择第一点")<BR> x = ptpick(0)<BR> y = ptpick(1)
ptpick = ThisDrawing.Utility.GetPoint(, "请选择下一点")<BR> x1 = ptpick(0)<BR> y1 = ptpick(1)
<BR> ThisDrawing.SendCommand ("_line" & vbCr & "x,y,0" & vbCr & "x1,y1,0" & vbCr)<BR> <BR>End Sub
但是同样是差不多的代码,画圆的时候就可以
Sub mycircle()<BR> <BR> Dim ptpick As Variant<BR> Dim x As Double<BR> Dim y As Double<BR> Dim z As Double<BR> ptpick = ThisDrawing.Utility.GetPoint(, "请选择第一点")<BR> x = ptpick(0)<BR> y = ptpick(1)<BR> z = 0<BR> <BR>static r as Double<BR> Dim returnString As String<BR> returnString = ThisDrawing.Utility.GetString(False, "输入半径:")<BR> If returnString = "" Then<BR> r = r<BR> Else<BR> r = Val(returnString)<BR> End If<BR> ThisDrawing.SendCommand ("_Circle" & vbCr & "x, y, 0" & vbCr & r & vbCr)<BR> <BR>End Sub
请教各位高手!
reply
Sub myl()<BR> Dim ptpick As Variant<BR> Dim x As Double<BR> Dim y As Double<BR> <BR> Dim x1 As Double<BR> Dim y1 As Double<BR> <BR> ptpick = ThisDrawing.Utility.GetPoint(, "请选择第一点")<BR> x = ptpick(0)<BR> y = ptpick(1)ptpick = ThisDrawing.Utility.GetPoint(, "请选择下一点")<BR> x1 = ptpick(0)<BR> y1 = ptpick(1)
Dim mac As String<BR> mac = "_line" & vbCr & VBA.str(x) & "," & VBA.str(y) & Chr(10) & VBA.str(x1) & "," & VBA.str(y1) & vbCr & vbCr<BR> mac = VBA.Replace(mac, " ", "")<BR> 'MsgBox mac<BR> ThisDrawing.SendCommand mac<BR> <BR>End Sub 谢谢版主!
页:
[1]