请教Utility.getpoint的用法
请教Utility.getpoint的用法<BR>初次接触VBA 因为课程设计里面要用 所以有点着急<BR>题目是画轴 <BR>我在窗体上面加了8个文字框 <BR>4个是轴的直径4个是轴的分段长度 但是在获取插入点的时候不会了<BR>找参考书的说是用<BR>insertPt = ThisDrawing.Utility.GetPoint(, "输入插入点:")<BR>语句 但是编译的时候总是出错<BR>请大家教我一下
或者说不用输入插入点,直接设置默认的插入点
<BR>还有 请教一下 VB里面数组如何初始化 举例说明 谢谢<BR>Private Sub cmdsure_Click()<BR> <BR> <BR> Dim D1 As Double<BR> Dim D2 As Double<BR> Dim D3 As Double<BR> Dim D4 As Double<BR> Dim L1 As Double<BR> Dim L2 As Double<BR> Dim L3 As Double<BR> Dim L4 As Double<BR> <BR> D1 = txtd1.Text<BR> D2 = txtd2.Text<BR> D3 = txtd3.Text<BR> D4 = txtd4.Text<BR> L1 = txtl1.Text<BR> L2 = txtl2.Text<BR> L3 = txtl3.Text<BR> L4 = txtl4.Text<BR> <BR> <BR> Dim sysOSMODE As Integer<BR> sysOSMODE = ThisDrawing.GetVariable("osmode")<BR> ThisDrawing.SetVariable "osmode", 0<BR> <BR> Dim p1, p2, p3, p4, p5, p6, p7, p8, insertPt(1) As Variant<BR> Dim utilObj As Object<BR> Set utilObj = ThisDrawing.Utility<BR> <BR> <BR> insertPt = ThisDrawing.Utility.GetPoint(, "输入插入点:")<BR> <BR> utilObj.CreateTypedArray p1, vbDouble, insertPt(0), insertPt(1),
0<BR> utilObj.CreateTypedArray p2, vbDouble, insertPt(0), insertPt(1)
+ D1, 0<BR> utilObj.CreateTypedArray p3, vbDouble, insertPt(0) + L1,
insertPt(1) - (D2 - D1) / 2, 0<BR> utilObj.CreateTypedArray p4, vbDouble, insertPt(0) + L1,
insertPt(1) + (D2 + D1) / 2, 0<BR> utilObj.CreateTypedArray p5, vbDouble, insertPt(0) + L1 + L2,
insertPt(1) - (D3 - D1) / 2, 0<BR> utilObj.CreateTypedArray p6, vbDouble, insertPt(0) + L1 + L2,
insertPt(1) + (D3 + D2) / 2, 0<BR> utilObj.CreateTypedArray p7, vbDouble, insertPt(0) + L1 + L2 +
L3, insertPt(1) - (D4 - D3) / 2, 0<BR> utilObj.CreateTypedArray p8, vbDouble, insertPt(0) + L1 + L2 +
L3, insertPt(1) + (D4 + D3) / 2, 0<BR> <BR> <BR> Dim mx As String<BR> mx = hehe<BR> <BR> <BR> 'create the block<BR> Set blockobj = ThisDrawing.Blocks.Add(insertPt, mx)<BR> Dim linea, lineb, linec, lined, linee As AcadLine<BR> Set linea = blockobj.AddLine(p1, p2)<BR> Set lineb = blockobj.AddLine(p3, p4)<BR> Set linec = blockobj.AddLine(p5, p6)<BR> Set lined = blockobj.AddLine(p7, p8)<BR> <BR> Dim blockrefobj As AcadBlockReference<BR> Set blockrefobj = ThisDrawing.ModelSpace.InsertBlock(insertPt,
mx, 1#, 1#, 1#, 0)<BR> <BR> ThisDrawing.Regen acActiveViewport<BR> <BR> <BR> <BR>End Sub 你的insertPt怎么定义错了
dim insertPt as Variant 楼上说得对
定义一个点如:
dim insertpt1(0 to 2)
dim insertpt2(0 to 2)
insertpt1(0)=0
insertpt1(1)=0
insertpt1(2)=0
insertpt2(0)=100
insertpt2(1)=100
insertpt2(2)=0
point inserpt 哦了 楼上的指点 你们说的错误是我在尝试其他方法的时候 忘了改回来的
我当初使用Utility.getpoint的时候 用的是insertPt
我再试试
页:
[1]