乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 30|回复: 1

为什么在以下情况不能够画线?请各位指教!

[复制链接]

14

主题

32

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
88
发表于 2005-5-12 12:43:00 | 显示全部楼层 |阅读模式
Private Sub ChOrDPath3_Click()
Form1.Hide
On Error Resume Next
Dim objlayer As AcadLayer
If IsNull(ThisDrawing.Layers.Item("ExtrudePath")) Then
Set objlayer = ThisDrawing.Layers.Add("ExtrudePath")
ThisDrawing.ActiveLayer = objlayer
Else
For Each objlayer In ThisDrawing.Layers
If objlayer.Name = "ExtrudePath" Then
ThisDrawing.ActiveLayer = objlayer
Exit For
End If
Next
End If
Dim sset As AcadSelectionSet
Dim i As Integer
i = ThisDrawing.SelectionSets.Count
While (i > 0)
Set sset = ThisDrawing.SelectionSets.Item(i - 1)
If sset.Name = "3dPLine" Then
sset.Delete
End If
i = i - 1
Wend
Set sset = ThisDrawing.SelectionSets.Add("3dPLine")
Dim gpcode(1) As Integer
Dim datavalue(1) As Variant
gpcode(0) = 0
datavalue(0) = "PolyLine"
gpcode(1) = 8
datavalue(1) = "ExtrudePath"
Dim objline As Acad3DPolyline
Dim topoint1(0 To 2) As Variant
topoint1(0) = Val(Form2.XPoint.Text)
topoint1(1) = Val(Form2.YPoint.Text)
topoint1(2) = Val(Form2.ZPoint.Text)
sset.Select acSelectionSetAll, , , gpcode, datavalue
If sset.Count > 1 Then
MsgBox "满足条件的拉伸路径存在多条,请选择一条!"
sset.Clear
sset.SelectOnScreen gpcode, datavalue
Set objline = sset.Item(0)
objline.Move objline.Coordinate(0), topoint1
Else
If sset.Count = 1 Then
Set objline = sset.Item(0)
objline.Move objline.Coordinate(0), topoint1
Else
For Each objlayer In ThisDrawing.Layers
If objlayer.Name = "ExtrudePath" Then
ThisDrawing.ActiveLayer = objlayer
End If
Exit For
Next
On Error GoTo ErrHandle
Dim p2 As Variant
p2 = ThisDrawing.Utility.GetPoint(, vbCr & "请输入下一点:")
Dim pnt(5) As Double
pnt(0) = Val(Form2.XPoint.Text): pnt(1) = Val(Form2.YPoint.Text): pnt(2) = Val(Form2.ZPoint.Text)
pnt(3) = p2(0): pnt(4) = p2(1): pnt(5) = p2(2)
Set objline = ThisDrawing.ModelSpace.Add3DPoly(pnt)
Do While True
p2 = ThisDrawing.Utility.GetPoint(p2, vbCr & "请输入下一点:")
objline.AppendVertex p2
Loop
ErrHandle:
End If
End If
(以上代码实现了“如果层ExtrudePath里面有超过一条3维多段线时,要求用户确定其中一条作为拉伸路径;如果恰好有条的话就自动作为拉伸路径;如果没有的话,就要求用户绘制一条3维多段线作为拉伸路径“。接下来的代码是为了获得当前三维多段线的相关参数,另外画一条三维多段线。可为什么运行的时候总是说过程无效?line1为空值)
Dim endpoint1(0 To 5) As Variant
Dim coord1 As Variant
Dim coord2 As Variant
coord1 = objline.Coordinate(1)
coord2 = objline.Coordinate(0)
Dim line1 As Acad3DPolyline
endpoint1(0) = 0: endpoint1(1) = coord1(1): endpoint1(2) = coord2(2)
endpoint1(3) = coord1(0): endpoint1(4) = coord1(1): endpoint1(5) = coord1(2)
Set line1 = ThisDrawing.ModelSpace.Add3DPoly(endpoint1)
End Sub
回复

使用道具 举报

34

主题

372

帖子

7

银币

中流砥柱

Rank: 25

铜币
508
发表于 2005-5-12 14:16:00 | 显示全部楼层
把程序注释一下吧,让大家很快能明白你的意思。
整段代码没有一句注释,大家读起来就要费很多时间,所以说老实话,很难有人耐心看完你的代码。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-2 15:20 , Processed in 0.569592 second(s), 57 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表