- 积分
- 24566
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-12-3 23:27:00
|
显示全部楼层
本帖最后由 作者 于 2004-12-5 22:26:55 编辑
测试代码:- Public TlsApp As New TlsApplicationPrivate WithEvents m_XhqReactor As TlsReactorPublic Sub TlsCadInit()
- TlsApp.Application = Application
- Set m_XhqReactor = TlsApp.Reactors("TlsXHQ")
- End SubPrivate Sub m_XhqReactor_DoubleClick(ByVal pObject As IAcadObject, ByVal Value As Variant)
- On Error GoTo ErrHandle
- Dim oBlock As AcadBlock
- Dim oText As AcadText
- Set oBlock = ThisDrawing.Blocks(pObject.Name)
- Set oText = oBlock(1)
- oText.TextString = InputBox("请输入序号", "TlsCad", oText.TextString)
- pObject.Update
- ErrHandle:
- End SubPrivate Sub m_XhqReactor_Erased(ByVal Value As Variant)
- MsgBox "Delete"
- End SubPrivate Sub m_XhqReactor_Modified(ByVal pObject As IAcadObject, ByVal Value As Variant)
- On Error GoTo ErrHandle Dim oLine As AcadLine
- Dim pStart, pEnd, pAngle, pDis
-
- Set oLine = ThisDrawing.HandleToObject(Value(0)) pStart = oLine.StartPoint
- pEnd = pObject.InsertionPoint
- pEnd = ThisDrawing.Utility.PolarPoint(pEnd, Atn(1) * 6, 5 * pObject.XScaleFactor)
- pAngle = ThisDrawing.Utility.AngleFromXAxis(pStart, pEnd)
- pDis = ((pStart(0) - pEnd(0)) ^ 2 + (pStart(1) - pEnd(1)) ^ 2) ^ 0.5 - 5 * pObject.XScaleFactor
- oLine.EndPoint = ThisDrawing.Utility.PolarPoint(pStart, pAngle, pDis)ErrHandle:
- End Sub
- Sub TlsXHQ()
- On Error GoTo ErrHandle
- Dim oLine As AcadLine
- Dim oBlock As AcadBlock
- Dim oText As AcadText
-
- s = ThisDrawing.Utility.GetString(False, "输入序号:")
- p1 = ThisDrawing.Utility.getpoint(, "输入第一点:")
- p2 = ThisDrawing.Utility.getpoint(p1, "输入第二点:")
- Set oLine = ThisDrawing.ModelSpace.AddLine(p1, p2)
-
- p1 = TlsApp.Utility.CreatePoint
- Set oBlock = ThisDrawing.Blocks.Add(p1, "*U")
- p1 = ThisDrawing.Utility.PolarPoint(p1, Atn(1) * 6, 5)
- oBlock.AddCircle p1, 5
- Set oText = oBlock.AddText(s, p1, 5)
- oText.Alignment = acAlignmentMiddleCenter
- oText.TextAlignmentPoint = p1
-
- m_XhqReactor.Add ThisDrawing.ModelSpace.InsertBlock(ThisDrawing.Utility.PolarPoint(p2, Atn(1) * 2, 5), oBlock.Name, 1, 1, 1, 0), Array(oLine.Handle)
-
- ErrHandle:
- End Sub
|
|