田草博客
日志搜索


 标题   内容 评论


网友交流QQ群:11740834 需注明申请加入原因

微信 公众号:ByCAD

邮箱:tiancao1001x126.com
ByCAD,微信公众号
首页 | 普通 | 电脑 | AutoCAD | VB/VB.NET | FLash | 结构 | 建筑 | 电影 | BIM | 规范 | 软件
-电信用户-|-网通用户-
-博客论坛-|-软件下载-
-网站导航-|-规范下载-
-BelovedFLash欣赏-

用户登陆
用户:
密码:
 

站点日历
73 2019 - 6 48
      1
2345678
9101112131415
16171819202122
23242526272829
30


站点统计

最新评论



空挡接龙 DatabaseServices.HostApplicationServices.FindFile
未知 沿着曲线将面域扫掠为三维曲面或三维实体   [ 日期:2017-07-03 ]   [ 来自:本站原创 ]  HTML


Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Namespace SolidCreation
    Public Class Commands
        <CommandMethod("SAP")> _
        Public Sub SweepAlongPath()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            ' Ask the user to select a region to extrude
            Dim peo1 As New PromptEntityOptions(vbLf & "Select profile or curve to sweep: ")
            peo1.SetRejectMessage(vbLf & "Entity must be a region, curve or planar surface.")
            peo1.AddAllowedClass(GetType(Region), False)
            peo1.AddAllowedClass(GetType(Curve), False)
            peo1.AddAllowedClass(GetType(PlaneSurface), False)
            Dim per As PromptEntityResult = ed.GetEntity(peo1)
            If per.Status <> PromptStatus.OK Then
                Return
            End If
            Dim regId As ObjectId = per.ObjectId
            ' Ask the user to select an extrusion path
            Dim peo2 As New PromptEntityOptions(vbLf & "Select path along which to sweep: ")
            peo2.SetRejectMessage(vbLf & "Entity must be a curve.")
            peo2.AddAllowedClass(GetType(Curve), False)
            per = ed.GetEntity(peo2)
            If per.Status <> PromptStatus.OK Then
                Return
            End If
            Dim splId As ObjectId = per.ObjectId
            Dim pko As New PromptKeywordOptions(vbLf & "Sweep a solid or a surface?")
            pko.AllowNone = True
            pko.Keywords.Add("SOlid")
            pko.Keywords.Add("SUrface")
            pko.Keywords.[Default] = "SOlid"
            Dim pkr As PromptResult = ed.GetKeywords(pko)
            Dim createSolid As Boolean = (pkr.StringResult = "SOlid")
            If pkr.Status <> PromptStatus.OK Then
                Return
            End If
            ' Now let's create our swept surface
            Dim tr As Transaction = db.TransactionManager.StartTransaction()
            Using tr
                Try
                    Dim sweepEnt As Entity = TryCast(tr.GetObject(regId, OpenMode.ForRead), Entity)
                    Dim pathEnt As Curve = TryCast(tr.GetObject(splId, OpenMode.ForRead), Curve)
                    If sweepEnt Is Nothing OrElse pathEnt Is Nothing Then
                        ed.WriteMessage(vbLf & "Problem opening the selected entities.")
                        Return
                    End If
                    ' We use a builder object to create
                    ' our SweepOptions
                    Dim sob As New SweepOptionsBuilder()
                    ' Align the entity to sweep to the path
                    sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath
                    ' The base point is the start of the path
                    sob.BasePoint = pathEnt.StartPoint
                    ' The profile will rotate to follow the path
                    sob.Bank = True
                    ' Now generate the solid or surface...
                    Dim ent As Entity
                    If createSolid Then
                        Dim sol As New Solid3d()
                        sol.CreateSweptSolid(sweepEnt, pathEnt, sob.ToSweepOptions())
                        ent = sol
                    Else
                        Dim ss As New SweptSurface()
                        ss.CreateSweptSurface(sweepEnt, pathEnt, sob.ToSweepOptions())
                        ent = ss
                    End If
                    ' ... and add it to the modelspace
                    Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                    Dim ms As BlockTableRecord = CType(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                    ms.AppendEntity(ent)
                    tr.AddNewlyCreatedDBObject(ent, True)
                    tr.Commit()
                Catch
                End Try
            End Using
        End Sub
    End Class
End Namespace

http://through-the-interface.typepad.com/through_the_interface/2010/01/sweeping-an-autocad-solid ... 1348761e46f970c#comment-6a00d83452464869e201348761e46f970c



[本日志由 tiancao1001 于 2017-07-31 03:31 PM 编辑]


暂时没有评论
发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:   注册? 验证:  防止恶意留言请输入问题答案:3*4=?  
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字

字体样式 文字大小 文字颜色
插入粗体文本 插入斜体文本 插入下划线
左对齐 居中对齐 右对齐
插入超级链接 插入邮件地址 插入图像
插入 Flash 插入代码 插入引用
插入列表 插入音频文件 插入视频文件
插入缩进符合
点击下载按钮 下标 上标
水平线 简介分割标记
表  情
 
Tiancao Blog All Rights Reserved 田草博客 版权所有
Copyright ©