コード例 #1
0
ファイル: CadHelper.cs プロジェクト: gispda/InterCad
 public SelectDimViewportJig(Editor acadEditor, Point3d basepnt, PromptNestedEntityThroughViewportOptions options)
 {
     SelectDimViewportJig.m_cadEditor = acadEditor;
     this.options           = options;
     this.m_dimlinestartpnt = basepnt;
     this.m_dimlineendpnt   = basepnt;
 }
コード例 #2
0
ファイル: CadHelper.cs プロジェクト: gispda/InterCad
 public SelectThroughViewportJig(PromptNestedEntityThroughViewportOptions options)
 {
     this.options = options;
 }
コード例 #3
0
ファイル: CadHelper.cs プロジェクト: gispda/InterCad
        public static PromptNestedEntityThroughViewportResult GetNestedEntityThroughViewport(this Editor acadEditor, PromptNestedEntityThroughViewportOptions options)
        {
            Document      acadDocument  = acadEditor.Document;
            Database      acadDatabase  = acadDocument.Database;
            LayoutManager layoutManager = LayoutManager.Current;

            SelectThroughViewportJig stvpJig = new SelectThroughViewportJig(options);

            PromptResult pointResult = acadEditor.Drag(stvpJig);

            if (pointResult.Status == PromptStatus.OK)
            {
                Point3d pickedPoint = stvpJig.Result.Value;

                PromptNestedEntityOptions pneOpions = options.Options;
                pneOpions.NonInteractivePickPoint    = pickedPoint;
                pneOpions.UseNonInteractivePickPoint = true;

                PromptNestedEntityResult pickResult = acadEditor.GetNestedEntity(pneOpions);

                if ((pickResult.Status == PromptStatus.OK) ||
                    (acadDatabase.TileMode) ||
                    (acadDatabase.PaperSpaceVportId != acadEditor.CurrentViewportObjectId))
                {
                    return(new PromptNestedEntityThroughViewportResult(pickResult));
                }
                else
                {
                    SelectionFilter vportFilter = new SelectionFilter(new TypedValue[] { new TypedValue(0, "VIEWPORT"),
                                                                                         new TypedValue(-4, "!="),
                                                                                         new TypedValue(69, 1),
                                                                                         new TypedValue(410, layoutManager.CurrentLayout) });

                    PromptSelectionResult vportResult = acadEditor.SelectAll(vportFilter);

                    if (vportResult.Status == PromptStatus.OK)
                    {
                        using (Transaction trans = acadDocument.TransactionManager.StartTransaction())
                        {
                            foreach (ObjectId objectId in vportResult.Value.GetObjectIds())
                            {
                                Viewport viewport = (Viewport)trans.GetObject(objectId, OpenMode.ForRead, false, false);

                                if (viewport.ContainsPoint(pickedPoint))
                                {
                                    pneOpions.NonInteractivePickPoint    = TranslatePointPsToMs(viewport, pickedPoint);
                                    pneOpions.UseNonInteractivePickPoint = true;

                                    acadEditor.SwitchToModelSpace();

                                    Application.SetSystemVariable("CVPORT", viewport.Number);

                                    PromptNestedEntityResult pneResult = acadEditor.GetNestedEntity(pneOpions);

                                    acadEditor.SwitchToPaperSpace();

                                    if (pneResult.Status == PromptStatus.OK)
                                    {
                                        return(new PromptNestedEntityThroughViewportResult(pneResult, objectId));
                                    }
                                }
                            }
                        }
                    }

                    return(new PromptNestedEntityThroughViewportResult(pickResult));
                }
            }
            else
            {
                return(new PromptNestedEntityThroughViewportResult(pointResult));
            }
        }