- 积分
- 23137
- 明经币
- 个
- 注册时间
- 2008-11-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2015-5-17 23:04:36
|
显示全部楼层
本帖最后由 zzyong00 于 2015-5-17 23:06 编辑
再来一个!
- Private Sub Command23_Click()
- AppActivate objCad.Caption
- Dim objPl1 As AcadLWPolyline, objPl2 As AcadLWPolyline, pt1 As Variant, blnESC As Boolean
- SelectSinglePLine objPl1, pt1, blnESC
- If blnESC Then Exit Sub
- On Error GoTo err1
- Dim dbl1 As Double, myPt1, myPt2, myPt3, dblA As Double, i As Long
- dbl1 = 3
- dbl1 = ThisDrawing.Utility.GetReal("请输入示坡线间距<3>:")
- Dim objCurve1 As New Curve
- Dim objL As AcadLine
- Set objCurve1.Entity = objPl1
- Dim DrtPt(2) As Double, ScdPt(2) As Double, FstPt(2) As Double, tmppt As Variant, lngDrt As Long
- tmppt = ThisDrawing.Utility.GetPoint(objCurve1.StartPoint, "请指定示坡方向:")
- DrtPt(0) = tmppt(0)
- DrtPt(1) = tmppt(1)
- DrtPt(2) = tmppt(2)
- tmppt = objCurve1.GetClosestPointTo(DrtPt)
- If Abs(tmppt(0) - DrtPt(0)) < EPS And Abs(tmppt(1) - DrtPt(1)) < EPS And Abs(tmppt(1) - DrtPt(1)) < EPS Then
- MsgBox "请不要用曲线上的点指定方向!", vbInformation + vbOKOnly, App.Title
- Exit Sub
- End If
- ScdPt(0) = objPl1.Coordinate(1)(0)
- ScdPt(1) = objPl1.Coordinate(1)(1)
- ScdPt(2) = 0
- FstPt(0) = objPl1.Coordinate(0)(0)
- FstPt(1) = objPl1.Coordinate(0)(1)
- FstPt(2) = 0
- lngDrt = Cmp_PolarAngel_arrP(DrtPt, ScdPt, FstPt) '取旋转方向
- Do While i * dbl1 < objCurve1.length
- myPt1 = objCurve1.GetPointAtDistance(i * dbl1)
- myPt2 = objCurve1.GetFirstDerivative(objCurve1.GetParameterAtDistance(i * dbl1))
- myPt2(0) = myPt1(0) + myPt2(0)
- myPt2(1) = myPt1(1) + myPt2(1)
- dblA = ThisDrawing.Utility.AngleFromXAxis(myPt1, myPt2) + lngDrt * PI / 2
- If i Mod 2 = 1 Then
- myPt3 = ThisDrawing.Utility.PolarPoint(myPt1, dblA, dbl1 / 2)
- Set objL = ThisDrawing.ModelSpace.AddLine(myPt1, myPt3)
- Else
- myPt3 = ThisDrawing.Utility.PolarPoint(myPt1, dblA, dbl1)
- Set objL = ThisDrawing.ModelSpace.AddLine(myPt1, myPt3)
- End If
- i = i + 1
- Loop
- ThisDrawing.Regen acActiveViewport
- Exit Sub
- err1:
- Debug.Print Err.Number
- If Err.Number = -2145320928 Then
- Err.Clear
- Resume Next
- End If
- End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|