using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using System.IO;
using System.Collections;
namespace pavpp
{
public class pavpp
{
[CommandMethod("PAVPP")]
public void Run()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
LayoutManager layoutMgr = LayoutManager.Current;
ObjectId psid = db.CurrentSpaceId;
Point2d pd;
Point3d pd3;
//Point2d pd02;
//Point3d pd03;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Layout lt = tr.GetObject(layoutMgr.GetLayoutId(layoutMgr.CurrentLayout), OpenMode.ForRead) as Layout;
BlockTableRecord btr = tr.GetObject(psid, OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId id in btr)
{
if (id.ObjectClass.IsDerivedFrom(RXClass.GetClass(typeof(BlockReference))))
{
BlockReference br = tr.GetObject(id, OpenMode.ForRead) as BlockReference;
BlockTableRecord acBlkTblRec = tr.GetObject(br.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
pd3 = br.Position;
Point3d Position = acBlkTblRec.Origin;
ed.WriteMessage("\n" + pd3);
ed.WriteMessage("\n" + Position);
foreach (ObjectId id1 in acBlkTblRec)
{
if (id1.ObjectClass.IsDerivedFrom(RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline))))
{
Autodesk.AutoCAD.DatabaseServices.Polyline pln = tr.GetObject(id1, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Polyline;
pd = pln.GetPoint2dAt(1);
//pd03 = pln.GetPoint3dAt(1);
//Matrix3d wcs2ucs = doc.Editor.CurrentUserCoordinateSystem.Inverse();
//Point3d Position1 = pd03.TransformBy(wcs2ucs);
ed.WriteMessage("\n" + pd);
}
}
}
}
tr.Commit();
}
}
}
}