首页 > 其他分享 >AutoCAD VBNET 获取曲线在3个基本平面的投影

AutoCAD VBNET 获取曲线在3个基本平面的投影

时间:2023-10-05 09:22:32浏览次数:32  
标签:Dim AutoCAD cur Color 投影 tr End VBNET

求取空间任意曲线在xoy/yoz/xoz平面的投影

 

 

 <CommandMethod(NameOf(TT_CurveProjected))>
 Public Sub TT_CurveProjected()
     Dim doc As Document = Application.DocumentManager.MdiActiveDocument
     Dim db As Database = doc.Database
     Dim ed As Editor = doc.Editor
     '将用户坐标系转换成世界坐标系
     If Application.GetSystemVariable("WORLDUCS").ToString() <> "1" Then
         ed.CurrentUserCoordinateSystem = Matrix3d.Identity
         ed.Regen()
     End If

     Try
         Dim peo As New PromptEntityOptions("选择PolyLine")
         With peo
             .SetRejectMessage("only Curve can be select")
             .AddAllowedClass(GetType(Curve), False)
         End With
         Dim per = ed.GetEntity(peo)
         If per.Status <> PromptStatus.OK Then Return
         Using tr As Transaction = db.TransactionManager.StartTransaction()
             Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
             Dim ms As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
             Dim oriCurve As Curve = per.ObjectId.GetObject(OpenMode.ForRead)
             Dim xoyPlane As New Plane(Point3d.Origin, Vector3d.ZAxis)
             Dim xozPlane As New Plane(Point3d.Origin, Vector3d.YAxis)
             Dim yozPlane As New Plane(Point3d.Origin, Vector3d.XAxis)
             '创建曲线在xoy平面的投影
             Dim cur = oriCurve.GetOrthoProjectedCurve(xoyPlane)
             cur.Color = Color.FromColorIndex(ColorMethod.ByAci, 150)
             ms.AppendEntity(cur)
             tr.AddNewlyCreatedDBObject(cur, True)

             '创建曲线在xoz平面的投影
             Dim curXoz = oriCurve.GetOrthoProjectedCurve(xozPlane)
             curXoz.Color = Color.FromColorIndex(ColorMethod.ByAci, 100)
             ms.AppendEntity(curXoz)
             tr.AddNewlyCreatedDBObject(curXoz, True)

             '创建曲线在yoz平面的投影
             Dim curYoz = oriCurve.GetOrthoProjectedCurve(yozPlane)
             curYoz.Color = Color.FromColorIndex(ColorMethod.ByAci, 50)
             ms.AppendEntity(curYoz)
             tr.AddNewlyCreatedDBObject(curYoz, True)

             tr.Commit()
         End Using
     Catch ex As System.Exception
         Application.ShowAlertDialog(ex.StackTrace)
     End Try
     'Application.UpdateScreen()
 End Sub

 

标签:Dim,AutoCAD,cur,Color,投影,tr,End,VBNET
From: https://www.cnblogs.com/NanShengBlogs/p/17743055.html

相关文章

  • AutoCAD VBNET 当前文档保存
    当前文档保存总出问题现在借助com的方法实现了保存文件<CommandMethod(NameOf(TT_SaveDrawing))>PublicSubTT_SaveDrawing()DimdocAsDocument=Application.DocumentManager.MdiActiveDocumentDimdbAsDatabase=doc.DatabaseDim......
  • Aveva Marine VBNET 编程系列====>读取drawing explorer的第2层级 Sub views
    接上期的内容,此次读取view的下一层几subview主要用到下面的方法获取view的第一个子级一个封装的类PublicClassDrawingExpolrerExPublicSharedFunctionDrawingHasViews(draftAppAsMarDrafting)AsBooleanDimvhAsMarElementHandleTry......
  • Aveva Marine VBNET 编程系列===>读取drawing explorer的第一层级 view
    今天我们研究下读取drawingexpolrer的第一层级:view下面的图纸的层级目录示意图,我们今天需要获取所有的view 主要用到2个方法:1#获取第一个元素MarDrafting.ElementChildFirstGetMethod() 2#获取相邻的元素MarDrafting.ElementSiblingNextGet Method  ......
  • Aveva Marine VBNET 编程系列-封装一个类
    由于AM的marapi的大部分类实现了IDisposable接口,所有避免内存过大,用了一般需要dispose下微软官方的解释:https://learn.microsoft.com/zh-cn/dotnet/api/system.idisposable?view=net-7.0 以下是MarDrafting类的定义,很显然它实现了IDisposable接口 ImportsSystem.Reflec......
  • Aveva Marine VBNET 编程系列-创建曲线
    显现的效果 代码实现:<MyAmFunctionAtt(NameOf(绘图控制),NameOf(新建曲线))>PublicSub新建曲线(wmAsWindowManager)DimdraftAppAsNewMarDraftingDimuiAsNewMarUi'ImportsAveva.Marine.UIDimutilyAsNewMarUtil'ImportsA......
  • Aveva Marine VBNET 编程系列-新建图纸,创建文字
    根据MarApi,创建图形文件,新建文字ImportsAveva.ApplicationFramework.PresentationImportsAveva.Marine.Drafting'marAPI.dllPublicClass绘图控制<MyAmFunctionAtt(NameOf(绘图控制),NameOf(新建图纸))>PublicSub新建图纸(wmAsWindowManager)Di......
  • ArcGIS地图投影与坐标系转换的方法
      本文介绍在ArcMap软件中,对矢量图层或栅格图层进行投影(即将地理坐标系转为投影坐标系)的原理与操作方法。  首先,地理坐标系与投影坐标系最简单的区别就是,地理坐标系用经度、纬度作为空间衡量指标,而投影坐标系用米、千米等长度单位作为空间衡量指标。  在GIS处理中,将原本为......
  • Aveva Marine VBNET 编程系列-修改程序快捷键
    修改HullDesign程序的主题以及菜单项的快捷键 引用的dll文件下面的是代码和快捷键配置文件:https://files.cnblogs.com/files/NanShengBlogs/AMShortCut.HullDesign.zip?t=1695908179&download=trueImportsAveva.ApplicationFramework.PresentationImportsAveva.Applic......
  • Aveva Marine VBNET 编程系列-搭建开发框架
    引用的DllAveva.ApplicationFramework.dllAveva.ApplicationFramework.Presentation菜单展示效果创建Attribute,用于反射来动态创建菜单,不用每次都去写commandPublicClassMyAmFunctionAttInheritsAttributePrivate_menuNameAsStringPublicPropertyM......
  • VBNET AUTOCAD 单行文字OBB有向包围盒的计算
    遇到要求单行文字包围和的需求,发现AutoCAD自带的算法仅能求出正交包围盒,如下图所示的粉色矩形我想获取下图下图所示蓝色矩形的部分及OBB计算方法图形示例:下面是完整的代码,其中求D点的坐标p1涉及到向量定比分点公式<CommandMethod(NameOf(TT_SingleTextOBB))>SubTT......