乐筑天下

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

瞬态代码在acad中工作,而不是在bricscad中

[复制链接]

7

主题

60

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
88
发表于 2017-9-27 16:43:32 | 显示全部楼层 |阅读模式
我做了一个测试prog,在用户选择时在屏幕上画一个围栏。
它在autocad中运行良好,但在bricscad v16中不行。我将很快在V17上尝试。
这是代码,非常典型的使用点监视器的示例例程。
您应该得到的是正在绘制的红色折线,就像绘制真正的样条线一样。
Escape杀死它,这只是一个示例prog。
  1. //C# Usings
  2. using System;
  3. using System.Collections;
  4. using SC = System.Collections;
  5. using System.Collections.Generic;
  6. using SCG = System.Collections.Generic;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using System.Diagnostics;
  10. using System.IO;
  11. using System.Windows.Forms;
  12. using SWF = System.Windows.Forms;
  13. using System.ComponentModel;
  14. using System.Drawing;
  15. using System.Runtime.InteropServices;
  16. using System.Xml;
  17. using System.Xml.Serialization;
  18. using SM = System.Math;
  19. using System.Linq;
  20. //AutoCad Usings
  21. #if ACAD
  22. using Autodesk.AutoCAD.Runtime;
  23. using Autodesk.AutoCAD.ApplicationServices;
  24. using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
  25. using Autodesk.AutoCAD.EditorInput;
  26. using AcEd = Autodesk.AutoCAD.EditorInput;
  27. using Autodesk.AutoCAD.DatabaseServices;
  28. using AcDb = Autodesk.AutoCAD.DatabaseServices;
  29. using Autodesk.AutoCAD.Geometry;
  30. using AcGe = Autodesk.AutoCAD.Geometry;
  31. using AcCo = Autodesk.AutoCAD.Colors;
  32. using Autodesk.AutoCAD.Windows;
  33. using AcWn = Autodesk.AutoCAD.Windows;
  34. using Autodesk.AutoCAD.GraphicsInterface;
  35. using Autodesk.AutoCAD.Interop;
  36. using Autodesk.AutoCAD.Customization;
  37. #endif
  38. #if BCAD
  39. using Teigha.DatabaseServices;
  40. using AcDb = Teigha.DatabaseServices;
  41. using Bricscad.EditorInput;
  42. using AcEd = Bricscad.EditorInput;
  43. using Teigha.Geometry;
  44. using AcGe = Teigha.Geometry;
  45. using AcCo = Teigha.Colors;
  46. using Teigha.Runtime;
  47. using Teigha.GraphicsInterface;
  48. using Bricscad.Runtime;
  49. using Bricscad.ApplicationServices;
  50. using AcAp = Bricscad.ApplicationServices.Application;
  51. using Bricscad.Windows;
  52. using AcWn = Bricscad.Windows;
  53. #endif
  54. [assembly: CommandClass(typeof(ProgTestingAcad.Program2))]
  55. namespace ProgTestingAcad {
  56.     public class Program2 {
  57.         [CommandMethod("TESTPTS2")]
  58.         public static void GetPts() {
  59.             Document dwg = AcAp.DocumentManager.MdiActiveDocument;
  60.             Editor ed = dwg.Editor;
  61.             MyptCmd cmd = new MyptCmd(dwg);
  62.             cmd.GetPts();
  63.         }
  64.     }
  65.     public class MyptCmd {
  66.         private Document _dwg;
  67.         private Editor _editor;
  68.         private List _points;
  69.         private List _origpoints = new List();
  70.         private Point2d _resPt;
  71.         private AcDb.Polyline _pline = null;
  72.         public MyptCmd(Document dwg) {
  73.             _dwg = dwg;
  74.             _editor = _dwg.Editor;
  75.         }
  76.         public void GetPts() {
  77.             _points = new List();
  78.             //get first point
  79.             PromptPointOptions opt = new PromptPointOptions("\nPick Point: ");
  80.             PromptPointResult res = _editor.GetPoint(opt);
  81.             if (res.Status == PromptStatus.OK) {
  82.                 _origpoints.Add(new AcGe.Point2d(res.Value.X, res.Value.Y));
  83.                 try {
  84.                     //Handling mouse cursor moving during picking
  85.                     _editor.PointMonitor += new PointMonitorEventHandler(_editor_PointMonitor);
  86.                     bool loop = true;
  87.                     //get more points
  88.                     while (loop) {
  89.                         if (!PickNewPoint())
  90.                             loop = false; //no point
  91.                         else
  92.                             _origpoints.Add(_resPt);
  93.                     }
  94.                 }
  95.                 catch {
  96.                     throw;
  97.                 }
  98.                 finally {
  99.                     ClearTransientGraphics();
  100.                     //Remove PointMonitor handler
  101.                     _editor.PointMonitor -= new PointMonitorEventHandler(_editor_PointMonitor);
  102.                 }
  103.             }
  104.         }
  105.         private bool PickNewPoint() {
  106.             PromptPointOptions opt = new PromptPointOptions("\nPick Point: ");
  107.             PromptPointResult res = _editor.GetPoint(opt);
  108.             if (res.Status == PromptStatus.OK) {
  109.                 _resPt = new AcGe.Point2d(res.Value.X, res.Value.Y);
  110.                 return true;
  111.             }
  112.             else {
  113.                 return false;
  114.             }
  115.         }
  116.         private void ClearTransientGraphics() {
  117.             TransientManager.CurrentTransientManager.EraseTransients(
  118.                 TransientDrawingMode.DirectShortTerm,
  119.                 128, new IntegerCollection());
  120.             if (_pline != null)
  121.                 _pline.Dispose();
  122.             _pline = null;
  123.         }
  124.         private void _editor_PointMonitor(object sender, PointMonitorEventArgs e) {
  125.             ClearTransientGraphics();
  126.             Point2d pt = new Point2d(e.Context.RawPoint.X, e.Context.RawPoint.Y);
  127.             bool go = true;
  128.             //figure new points
  129.             //set _points to orig and add point
  130.             //we must do this as we cannot simply add a point
  131.             _points = new List();
  132.             _points.AddRange(_origpoints);
  133.             _points.Add(pt);
  134.             //draw new _pline
  135.             if (go) {
  136.                 _pline = new AcDb.Polyline(_points.Count);
  137.                 for (int i = 0; i < _points.Count; i++) {
  138.                     _pline.AddVertexAt(i, _points[i], 0.0, 0.0, 0.0);
  139.                 }
  140.                 _pline.ColorIndex = 1;
  141.                 TransientManager.CurrentTransientManager.AddTransient(
  142.                     _pline, TransientDrawingMode.DirectShortTerm, 128
  143.                     , new IntegerCollection());
  144.             }
  145.         }
  146.     }
  147. }

有什么想法吗?
我尝试了DirectTop大多数和其他想法,那没关系。
thx

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2017-9-27 17:09:44 | 显示全部楼层
我注意到BricsCAD V17不会在PointMonitor期间更新瞬态实体,除非您滚动鼠标滚轮。只是静态瞬态实体工作正常。
Gent中的程序员知道这一点并将检查可能性。
回复

使用道具 举报

7

主题

60

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
88
发表于 2017-9-27 17:32:15 | 显示全部楼层
不,不……。
开枪,我撞到虫子了
我在acad中做了大量编程,并且在bcad中尝试过瞬态,因此从未想过它们会在pointmonitor中表现不好<我希望他们能解决这个问题<谢谢你的提醒,huiz!
回复

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2017-9-28 03:57:12 | 显示全部楼层
至少他们比另一家CAD软件公司更认真
回复

使用道具 举报

7

主题

60

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
88
发表于 2017-9-28 09:45:07 | 显示全部楼层
黑客警报
if(go)
{
_ pline=新的AcDb.Polyline(_points.Count)
用于(int i=0;i
{
_ pline。AddVertexAt(i,_points[i],0.0,0.0,0.0)
}
_ pline。色度指数=1
TransientManager.CurrentTransientManager.AddTransient(
_ pline,瞬态绘图模式。DirectShortTerm,128
,新的IntegerCollection())
editor.SetCurrentView(_editor.GetCurrentView());//
}
编辑:需要这样处理。
使用(ViewTableRecord rec=_editor.GetCurrentView())进行编辑
{
编辑器SetCurrentView(rec)
}
可能有更好的替代方案,这在大型图纸上似乎有点滞后。
回复

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2017-9-28 13:28:26 | 显示全部楼层
这真的很神奇,”....这真的是太神奇了。这实在是太神奇了,我想把它偷出来。-Zaphod Beeblebrox
这很有效,太简单了!非常感谢你的回复,现在我的Bricscad工作的很好,我欠你的!
回复

使用道具 举报

7

主题

60

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
88
发表于 2017-10-3 07:51:03 | 显示全部楼层
确实,完美!在AutoCAD变体中,我没有设置当前视图,它以这种方式工作正常。如果我将SetCurrentView添加到代码中,它也可以在PointMonitor的BricsCAD中工作!
对不起詹姆斯,我错误地通知你,我不知道这个聪明的解决方案!
回复

使用道具 举报

85

主题

404

帖子

7

银币

中流砥柱

Rank: 25

铜币
751
发表于 2017-10-3 11:07:38 | 显示全部楼层
惠兹,你是对的,bricsys正在努力,他们也告诉我。
我还添加了一个#if BCAD...语句来运行bcad。
像这样的瞬态的使用将改变我已经做了这么多工具。
我曾经使用grDrew,但与瞬态相比,这是过时的。
回复

使用道具 举报

1

主题

5

帖子

1

银币

初来乍到

Rank: 1

铜币
9
发表于 2017-10-25 23:41:34 | 显示全部楼层
谢谢你的变通方法,丹尼尔。在这里工作也不错
仅供参考,自Bricscad V18.1.02测试版起,瞬态仍然存在,需要.SetCurrentView调用才能显示。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-2-4 12:44 , Processed in 0.198009 second(s), 70 queries .

© 2020-2025 乐筑天下

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