- UID
- 76071
- 积分
- 1505
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-8-30
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
注册压缩包里的Dll(AutoCad版本为2005),并在VBA里引用
在ThisDrawing模块加入下列示例代码
- Public TlsApp As New TlsApplication
- Private WithEvents m_XhqReactor As TlsReactor
- Public Sub TlsCadInit()
- TlsApp.Application = Application
- Set m_XhqReactor = TlsApp.Reactors("TlsXHQ")
- End Sub
- Private 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 Sub
- Private Sub m_XhqReactor_Erased(ByVal Value As Variant)
- MsgBox "Delete"
- End Sub
- Private 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
Acad2005Doc.lsp文件加入:
- (vla-RunMacro (vlax-get-acad-object) "tlscadinit")
复制代码
上面的示例是一个简单的序号球原型,TlsXHQ宏创建序号球实体
移动球体,直线会跟随,双击球体,可以改变序号球的值 |
|