Find Clip Id from NonRectangularViewPort Object ID t?

Find Clip Id from NonRectangularViewPort Object ID t?

JanetDavidson
Advocate Advocate
1,577 Views
6 Replies
Message 1 of 7

Find Clip Id from NonRectangularViewPort Object ID t?

JanetDavidson
Advocate
Advocate

Hello,

Need help  and could not find a solution for it.

I have  the ID of non rectangular view port and I need to find the Polyline attached to it.

How do you do that ?

Thanks,

 

0 Likes
Accepted solutions (1)
1,578 Views
6 Replies
Replies (6)
Message 2 of 7

Alexander.Rivilis
Mentor
Mentor

Hi, Janet!

Please attach a simplest dwg-file with such viewport and correspondent Polyline.

 

P.S.: Maybe method Viewport.NonRectClipEntityId can help you?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi,

 

Once you have a viewport ObjectId, use viewport.NonRectClipEntityId (that should be not ObjectId.Null) to get its non-rectangular viewport, see the following code snippet:

 

transaction.GetObject(viewport.NonRectClipEntityId, OpenMode.ForRead) as Polyline

 

-Khoa

Message 4 of 7

JanetDavidson
Advocate
Advocate

Thanks Khao for your time,

 Actually My Problem it the otherway around.  I mean I want the PolyLine ObjectId of sorrouding ViewPort (Which I have the ID.

 

0 Likes
Message 5 of 7

JanetDavidson
Advocate
Advocate

Hi Alex,

I need the object ID of Polyline which is attached to viewport.

 

0 Likes
Message 6 of 7

Alexander.Rivilis
Mentor
Mentor
Accepted solution
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

[assembly: CommandClass(typeof(Rivilis.Lesson))]

namespace Rivilis
{
  public class Lesson
  {
    [CommandMethod("TestViewport")]
    public void TestViewport()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      PromptSelectionResult res = ed.GetSelection();
      if (res.Status == PromptStatus.OK) {
        using (Transaction t = doc.TransactionManager.StartTransaction()) {
          foreach (ObjectId id in res.Value.GetObjectIds()) {
            Viewport vp = t.GetObject(id, OpenMode.ForRead) as Viewport;
            if (vp != null) {
              ObjectId idPoly = vp.NonRectClipEntityId;
              if (!idPoly.IsNull) {
                // ObjectId of polyline
                ed.WriteMessage("\nid = {0} NonRectClipEntityId = {1}", id, idPoly);
              }
              else {
                ed.WriteMessage("\nid = {0} Viewport is not clipping with polyline", id);
              }
            }
            else {
              ed.WriteMessage("\nid = {0} is not Viewport", id);
            }
          }
          t.Commit();
        }
      }
    }
  }
}

 

http://www.developerfusion.com/tools/convert/csharp-to-vb/  for converting C# to VB.NET

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 7 of 7

JanetDavidson
Advocate
Advocate

 

Alex Thank you so much. That was it.

 

 

0 Likes