明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2978|回复: 3

请教Utility.getpoint的用法

[复制链接]
发表于 2004-12-29 15:57:00 | 显示全部楼层 |阅读模式
请教Utility.getpoint的用法
初次接触VBA 因为课程设计里面要用 所以有点着急
题目是画轴
我在窗体上面加了8个文字框
4个是轴的直径4个是轴的分段长度 但是在获取插入点的时候不会了
找参考书的说是用
insertPt = ThisDrawing.Utility.GetPoint(, "输入插入点:")
语句 但是编译的时候总是出错
请大家教我一下 或者说不用输入插入点,直接设置默认的插入点
还有 请教一下 VB里面数组如何初始化 举例说明 谢谢
Private Sub cmdsure_Click()


Dim D1 As Double
Dim D2 As Double
Dim D3 As Double
Dim D4 As Double
Dim L1 As Double
Dim L2 As Double
Dim L3 As Double
Dim L4 As Double

D1 = txtd1.Text
D2 = txtd2.Text
D3 = txtd3.Text
D4 = txtd4.Text
L1 = txtl1.Text
L2 = txtl2.Text
L3 = txtl3.Text
L4 = txtl4.Text


Dim sysOSMODE As Integer
sysOSMODE = ThisDrawing.GetVariable("osmode")
ThisDrawing.SetVariable "osmode", 0

Dim p1, p2, p3, p4, p5, p6, p7, p8, insertPt(1) As Variant
Dim utilObj As Object
Set utilObj = ThisDrawing.Utility


insertPt = ThisDrawing.Utility.GetPoint(, "输入插入点:")

utilObj.CreateTypedArray p1, vbDouble, insertPt(0), insertPt(1), 0
utilObj.CreateTypedArray p2, vbDouble, insertPt(0), insertPt(1) + D1, 0
utilObj.CreateTypedArray p3, vbDouble, insertPt(0) + L1, insertPt(1) - (D2 - D1) / 2, 0
utilObj.CreateTypedArray p4, vbDouble, insertPt(0) + L1, insertPt(1) + (D2 + D1) / 2, 0
utilObj.CreateTypedArray p5, vbDouble, insertPt(0) + L1 + L2, insertPt(1) - (D3 - D1) / 2, 0
utilObj.CreateTypedArray p6, vbDouble, insertPt(0) + L1 + L2, insertPt(1) + (D3 + D2) / 2, 0
utilObj.CreateTypedArray p7, vbDouble, insertPt(0) + L1 + L2 + L3, insertPt(1) - (D4 - D3) / 2, 0
utilObj.CreateTypedArray p8, vbDouble, insertPt(0) + L1 + L2 + L3, insertPt(1) + (D4 + D3) / 2, 0


Dim mx As String
mx = hehe


'create the block
Set blockobj = ThisDrawing.Blocks.Add(insertPt, mx)
Dim linea, lineb, linec, lined, linee As AcadLine
Set linea = blockobj.AddLine(p1, p2)
Set lineb = blockobj.AddLine(p3, p4)
Set linec = blockobj.AddLine(p5, p6)
Set lined = blockobj.AddLine(p7, p8)

Dim blockrefobj As AcadBlockReference
Set blockrefobj = ThisDrawing.ModelSpace.InsertBlock(insertPt, mx, 1#, 1#, 1#, 0)

ThisDrawing.Regen acActiveViewport



End Sub
发表于 2004-12-29 17:32:00 | 显示全部楼层
你的insertPt怎么定义错了


dim insertPt as Variant
发表于 2004-12-29 18:00:00 | 显示全部楼层
楼上说得对


定义一个点如:


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
 楼主| 发表于 2004-12-29 18:03:00 | 显示全部楼层
哦了         楼上的指点 你们说的错误是我在尝试其他方法的时候 忘了改回来的


我当初使用Utility.getpoint的时候 用的是insertPt


我再试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 21:37 , Processed in 0.182721 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表