cass7.1或者AutoCAD2004并安装了vba环境
在vba窗口左侧上部工程窗口内部,右键选择“插入”中的”模块“
在模块右侧代码窗口中输入如下内容:Option ExplicitSub bmjhs() Dim entry As AcadEntity, basePnt As Variant Dim textobj As AcadText, text As String Dim height As Double, pd As Variant ThisDrawing.Utility.GetEntity entry, basePnt, '选择宗地线' text = Format(entry.Area / 666.67, '0.00') '2000 * 3 height = 1.21'文字高度 pd = ThisDrawing.Utility.GetPoint(, '选择面积注记位置') Set textobj = ThisDrawing.ModelSpace.AddText(text, pd, height)End Sub
双击左侧工程窗口中AutoCAD对象中的ThisDrawing,可以看到右侧代码窗口改变为空白。
在ThisDrawing的右侧代码窗口中输入如下内容:Option ExplicitPublic TestLoad As BooleanPrivate Sub AcadDocument_EndCommand(ByVal CommandName As String) If Not TestLoad Then ThisDrawing.SendCommand '(defun c:ss()(vl-vbarun ''bmjhs'')(princ))(princ)' & vbCr TestLoad = True End IfEnd Sub
点击左上的保存按钮保存。在弹出的窗口中选择保存路径和保存的名字。
回到cad绘图窗口。这个编辑的表宗地面积工程的vba宏名为“bmjhs”,命令行调用命令自定义设置的是“ss”.运行命令标注情况见图。
标注的面积单位为亩,文字高设置的1.21,当然这些参数都可以修改。爱好开发的朋友可以自己根据喜好自行修改。
具体操作中如果遇到问题可以联系我,大家互相学习交流。