乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 37|回复: 0

net下cad对象动画问题

[复制链接]

9

主题

16

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
52
发表于 2015-1-26 18:33:00 | 显示全部楼层 |阅读模式
大家好,我想做一个在cad里的动态演示,用的timer控制时间,5秒间隔还行,1秒以下cad就挂了为什么?源码如下,求高手帮忙,多谢。
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
        Dim str As String = "The Elapsed event was raised at {0}" & e.SignalTime
        Dim str2 As String = str
        Dim i As Integer = 0
        Dim id As ObjectId
        For Each id In mBodyId
            intEnd = Now.Ticks
            tsnResult = New TimeSpan(intEnd - intStart)
            Dim tt As Double = Val(tsnResult.TotalMilliseconds.ToString) / 1000
            Dim v As Double = 1
            Dim x As Double = v * tt
            Dim angle As Single = 0
            ChangeBlockRefInsPointAndAngle(id, New Point3d(x, 2 * x + 1, 0), angle)        Next
End Sub Public Shared Sub ChangeBlockRefInsPointAndAngle(ByVal BlockRefId As ObjectId, ByVal Newposition As Point3d, ByVal angle As Single)        Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
        ''启动一个事务   Start a transaction
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim ent As BlockReference = acTrans.GetObject(BlockRefId, OpenMode.ForWrite)
            '' 创建一个矩阵并利用一个矢量将圆从点(0,0,0)移动到点(2,0,0)     Create a matrix and move the circle using a vector from (0,0,0) to (2,0,0)
            Dim acPt3d As Point3d = New Point3d(ent.Position.X, ent.Position.Y, 0)
            Dim acVec3d As Vector3d = acPt3d.GetVectorTo(New Point3d(Newposition.X, Newposition.Y, 0))
            ent.TransformBy(Matrix3d.Displacement(acVec3d))
            '' 保存新对象到数据库中   Save the new objects to the database
            acTrans.Commit()
            Autodesk..ApplicationServices.Application.UpdateScreen()
        End Using    End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-28 18:46 , Processed in 0.430382 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表