乐筑天下

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

Editor.SelectWindowPolygon问题

[复制链接]

3

主题

6

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2012-1-22 12:18:00 | 显示全部楼层 |阅读模式
I found a intersting issue when using
Editor.SelectWindowPolygon()/SelectCrossingPolygon​(), that cost me quite
sime time to debug my project. The problem is, the selecting polygon
(crossing or window) MUST be within Acad editor's current view. That is, the
polygon must be entirely viewable within the current view. If part of the
polygon is out side the current view, the returned PromtSelectionResult's
Status property will be "Error".
Backgroud: in my project, I need to find some entities with a closed
polyline. So, I used the closed polyline as selecting polygon with the
SelectCrossingPolygon() method. During my code executing, the drawing's view
could be zoomed/paned so that the polyline may be moved partly outside
current view. The result my find entity logic was not consistent: some time
it finds entities it is supposed to, some time it does not find. I
eventually foudn the reason. Here is the testing code:
[CommandMethod("CSTest")]
public static void CrossingPolygonSelect()
{
    Document dwg =
Autodesk..ApplicationServices.Application.D​ocumentManager.MdiActiveDocument;
    //Pick a polyline as selecting crossing polygon
    PromptEntityResult res = dwg.Editor.GetEntity("\nPick a polyline:");
    if (res.Status != PromptStatus.OK) return;
    //Get selecting polyline object
    Polyline pline = null;
    using (Transaction tran =
dwg.Database.TransactionManager.StartTransaction()​)
    {
        pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);
    }
    //Get Poin3dCollection
    Point3dCollection pts = new Point3dCollection();
    for (int i = 0; i CPolygon", and managed to move part of selecting
polygon outside current view. The result was always correct, i.e. the "With
View" requirement is only applies programatical selecting.
Since the poor documentation of ObjectARX NET API, I could not find any
information on if it is be design or it is a bug, I post the issue here.
So, I work around to this iisue in my project would be to zoom to extents
before using SelectCrossingPolygon()/SelectWindowPolygon(), so that the
selecting polygon is shown entirely with the current view. This work around,
of cause, would cause issue if the drawing size is huge: zooming in this
case takes time if regen is required. Fortunately, the drawings my project
deals are all fairly small in size.
真是坑爹,刚好遇到这个问题,害的我调试了很久,原来真的如上所说这样。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-15 21:08 , Processed in 0.321949 second(s), 54 queries .

© 2020-2025 乐筑天下

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