public Scale3d getMVBScale(string MVBblockName)
{
Scale3d RetValue = new Scale3d();
if (SourceDirectoryDWGPath == null)
{
// Source path empty
return RetValue;
}
try
{
// Путь к файлу
string SourcePath = SourceDirectoryDWGPath + "\\" + MVBblockName + ".DWG";
Autodesk.AutoCAD.DatabaseServices.Database dbSource = new Database(false, true);
dbSource.ReadDwgFile(SourcePath, System.IO.FileShare.Read, true, "");
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = dbSource.TransactionManager;
Transaction t = tm.StartTransaction();
BlockTable bt = tm.GetObject(dbSource.BlockTableId, OpenMode.ForRead, false) as BlockTable;
BlockTableRecord btr = tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false) as BlockTableRecord;
foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId id in btr)
{
try
{
Entity ent1 = tm.GetObject(id, OpenMode.ForRead) as Entity;
string entType = ent1.GetType().ToString();
if(entType == "Autodesk.Aec.DatabaseServices.MultiViewBlockReference")
{
MultiViewBlockReference MVBRef = tm.GetObject(id, OpenMode.ForRead) as MultiViewBlockReference;
RetValue = MVBRef.Scale;
}
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show("Ошибка" + ex.Message);
}
}
t.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show("Ошибка" + ex.Message);
return RetValue;
}
return RetValue;
}