乐筑天下

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

[编程交流] lisp到vba

[复制链接]

1

主题

56

帖子

80

银币

初来乍到

Rank: 1

铜币
1
发表于 2022-7-6 17:54:52 | 显示全部楼层
.网对不起,我帮不了你,我可能比那里的任何人都环保
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 18:00:49 | 显示全部楼层
 
下面是VB中的一个示例。净额。我在VB方面没有太多经验。NET-我的大部分。到目前为止,C#一直在使用Net work,因此它可能没有尽可能简洁明了。
 
该项目应包括以下内容:
 
导入Autodesk。AutoCAD。运行时
导入Autodesk。AutoCAD。应用程序服务
导入Autodesk。AutoCAD。数据库服务
导入Autodesk。AutoCAD。编辑输入
导入Autodesk。AutoCAD。几何学
 
  1. Public Sub PlinePtAtDist()
  2.        Dim db As Database = HostApplicationServices.WorkingDatabase
  3.        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
  4.        db.Pdmode = 66 'just to make the points more visible
  5.        Dim tr As Transaction = db.TransactionManager.StartTransaction()
  6.        Try
  7.            Dim peo As PromptEntityOptions = New PromptEntityOptions(vbCr & "Select a lwpline: ")
  8.            peo.SetRejectMessage(vbCr & "Please select lightweight polyline only! ")
  9.            peo.AddAllowedClass(GetType(Polyline), True)
  10.            Dim per As PromptEntityResult = ed.GetEntity(peo)
  11.            If per.Status <> PromptStatus.OK Then Exit Sub
  12.            Dim pl As Polyline = tr.GetObject(per.ObjectId, OpenMode.ForRead)
  13.            Dim len As Double = pl.Length
  14.            Dim pdo As PromptDoubleOptions = New PromptDoubleOptions(vbCr & "Enter distance from startpoint: ")
  15.            pdo.AllowNegative = False
  16.            pdo.AllowZero = True
  17.            pdo.DefaultValue = len
  18.            pdo.AllowArbitraryInput = False
  19.            Dim pdr As PromptDoubleResult = ed.GetDouble(pdo)
  20.            If pdr.Status <> PromptStatus.OK Or pdr.Value > len Then Exit Sub
  21.            Dim pt As Point3d = pl.GetPointAtParameter(pl.GetParameterAtDistance(pdr.Value)) 'crux of the process
  22.            Dim ptAtDist As DBPoint = New DBPoint(pt)
  23.            Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
  24.            btr.AppendEntity(ptAtDist)
  25.            tr.AddNewlyCreatedDBObject(ptAtDist, True)
  26.            tr.Commit()
  27.        Catch ex As Exception
  28.            tr.Abort()
  29.            ed.WriteMessage("Error during execution! " & ex.Message)
  30.        Finally
  31.            tr.Dispose()
  32.        End Try
  33.    End Sub  
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 18:05:39 | 显示全部楼层
我想我应该通过说我还是一个相对新的(6个月)来限定之前的帖子。Net的任何伪装。我的大部分工作都是在C语言中完成的,但这应该意味着我只走了一小段路。
 
我相信前一篇文章中的代码会起作用,但可能需要额外注意,使其更“防弹”。
 
下面是C版本(我包含了更多的实体)。这可能是一个有趣的比较。
 
顺便提一下,我欢迎对该准则的任何评论和/或批评。
 
 
 
 
 
该项目应包括:
 
使用系统;
使用Autodesk。AutoCAD。运行时间;
使用Autodesk。AutoCAD。应用服务;
使用Autodesk。AutoCAD。数据库服务;
使用Autodesk。AutoCAD。几何学
使用Autodesk。AutoCAD。编辑输入;
 
 
  1.         static public void PlinePtAtDist()
  2.        {
  3.            // Obtain Database and Editor
  4.            Database db = HostApplicationServices.WorkingDatabase;
  5.            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
  6.            db.Pdmode = 66; // to make point more visible
  7.            PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect a pline or spline entity: ");
  8.            entOpts.SetRejectMessage("\nPlease select LWPoly, 2DPoly, 3DPoly, or spline only! ");
  9.            entOpts.AddAllowedClass(typeof(Polyline), true);
  10.            entOpts.AddAllowedClass(typeof(Polyline2d), true);
  11.            entOpts.AddAllowedClass(typeof(Polyline3d), true);
  12.            entOpts.AddAllowedClass(typeof(Spline), true);
  13.            using (Transaction tr = db.TransactionManager.StartTransaction())
  14.            {
  15.                PromptEntityResult prEntRes = ed.GetEntity(entOpts);
  16.                if (prEntRes.Status != PromptStatus.OK) return; //terminate if no object selected
  17.                Curve crv = (Curve)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead);
  18.                Double len = crv.GetDistanceAtParameter(crv.EndParam); //total length of curve
  19.                PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter distance from startpoint: ");
  20.                pdo.AllowNegative = false;
  21.                pdo.AllowZero = true;
  22.                pdo.DefaultValue = len;
  23.                pdo.AllowArbitraryInput = false;
  24.                PromptDoubleResult pdr = ed.GetDouble(pdo);
  25.                if (pdr.Status != PromptStatus.OK || pdr.Value > len) return;//value has been entered and less than total
  26.                Point3d pt = crv.GetPointAtParameter(crv.GetParameterAtDistance(pdr.Value));//crux of routine
  27.                DBPoint ptAtDist = new DBPoint(pt);
  28.                try
  29.                {
  30.                    BlockTableRecord btr = (BlockTableRecord)(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite));
  31.                    btr.AppendEntity(ptAtDist);
  32.                    tr.AddNewlyCreatedDBObject(ptAtDist, true);
  33.                    tr.Commit();
  34.                }
  35.                catch (System.InvalidOperationException ex)
  36.                {
  37.                    tr.Abort();
  38.                    ed.WriteMessage("\nProblem adding point at distance!");
  39.                    ed.WriteMessage(ex.Message);
  40.                }
  41.                finally
  42.                {
  43.                    ed.WriteMessage("\nPoint at Distance command terminated.");
  44.                }
  45.            }
  46.        }
回复

使用道具 举报

28

主题

130

帖子

126

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
154
发表于 2022-7-6 18:10:57 | 显示全部楼层
肖恩,
 
谢谢你。
 
我也在看“你好,世界!!!”vb。net示例在网络周围浮动。
 
但是谢谢你,这帮了大忙
 
我只需要了解如何访问这些功能。
 
我仍会看一看,并会尽快发回。
 
干杯
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 19:58 , Processed in 0.587972 second(s), 58 queries .

© 2020-2025 乐筑天下

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