zzyong00 发表于 2015-4-5 23:01:00

vba/vb编写的标注道路桩号的源代码!

在本论坛的lisp版,有些高手放出了标注桩号的一些lisp代码,但在vba/vb版,却一个也没有,客观上讲,这是vba的一些弱项导致的,在vba中,没有Curve类,也没有vlax-curve-get族函数,如下:
vlax-curve-getPointAtDist
vlax-curve-getPointAtParam ;
vlax-curve-getDistAtPoint ;
vlax-curve-getDistAtParam ;
vlax-curve-getParamAtPoint ;;
vlax-curve-getParamAtDist ;;
vlax-curve-getStartParam ;;
vlax-curve-getendParam ;;
vlax-curve-getStartPoint ;;;
vlax-curve-getEndPoint;;
vlax-curve-getFirstDeriv;;
vlax-curve-getSecondDeriv;;
vlax-curve-getSecondDeriv
如果自己实现以上函数,达到Autodesk函数的水平,实在不容易(也不是不可能),幸好,我们有vb调用lisp的类VLAX.cls(BY Frank Oquendo),而且,这位大神Frank Oquendo,还实现了Curve.cls类,让我们后来人轻松了很多!在此,我向前辈致敬!
由于源码中用的很多函数或过程都在这个帖子:
所以,还请各位移步!
看效果:

雪山飞狐_lzh 发表于 2015-4-5 23:30:00


刚看了下 efan的是用Arx做得Com组件,,不过支持的版本不多
原则上用VBA可以直接调用Arx的函数,efan以前也做过很多研究
有时间的话 我试试用.Net做个Com库看看

zzyong00 发表于 2015-4-5 23:46:00


我没有2013,我用2014 x64测试他的arx,好像输出一个时间,但对象不能创建成功,不知道他的arx设置有过期时间,还是的确无法调用!
期盼雪版的.Net版的Curve类com库出世!

zzyong00 发表于 2015-4-5 23:56:00


刚才在2004下测试efan的arx是成功的,不过,efan封装的不全,没有vlax-curve-getFirstDeriv,vlax-curve-getSecondDeriv

雪山飞狐_lzh 发表于 2015-4-6 20:42:00


1.0测试版 解压上面文件后,把他们放到d:\TlsCad\Bin里面 本来写注册表可以直接做到程序里 但是测试版先随意了
运行1.reg注册
然后在cad里nerload安装。。。正式版上面的步骤会少掉
VBA引用TlsCad.Common.tlb测试代码Sub tt()
Dim cm As TlsCad_Common.CurveManager
Set cm = Application.GetInterfaceObject("TlsCad.Common.CurveManager")
Dim obj As AcadEntity, pnts(1)
ThisDrawing.Utility.GetEntity obj, pnts(0)
Dim cc As TlsCad_Common.Curve
Set cc = cm.Add(obj.ObjectID)
pnts(0) = cc.GetClosestPointTo(pnts(0), False)
pnts(1) = ThisDrawing.Utility.GetPoint()
pnts(1) = cc.GetClosestPointTo(pnts(1), False)
cc.SplitByParams cc.GetParamsByPoints(pnts)
obj.Delete
cc.Dispose
End Sub

zzyong00 发表于 2015-4-6 21:22:00

雪山飞狐_lzh 发表于 2015-4-6 20:42
我在autocad2008下也没用调用成功
页: [1]
查看完整版本: vba/vb编写的标注道路桩号的源代码!