using System;
using AppServCore = Autodesk.AutoCAD.ApplicationServices.Core;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
namespace Testing
{
public class DimScale
{
[CommandMethod("DS")]
public static void DS()
{
var doc = AppServCore.Application.DocumentManager.MdiActiveDocument;
if (doc == null)
return;
var db = doc.Database;
var ed = doc.Editor;
double value;
using (doc.LockDocument())
{
using (var tr = db.TransactionManager.StartTransaction())
{
var pp1 = ed.GetPoint("Выберете опорную точку: ") as PromptPointResult;
if (pp1.Status != PromptStatus.OK)
{
return;
}
var acSelSetPrompt = ed.GetSelection() as PromptSelectionResult;
if (acSelSetPrompt.Status == PromptStatus.OK)
{
var acSSet = acSelSetPrompt.Value;
foreach (SelectedObject acSelSetObj in acSSet)
{
if (acSelSetObj != null)
{
var alignDim = tr.GetObject(acSelSetObj.ObjectId, OpenMode.ForWrite) as AlignedDimension;
if (alignDim != null)
{
value = Math.Round(alignDim.Measurement);
alignDim.DimensionText = Convert.ToString(value);
}
}
}
foreach (SelectedObject acSelSetObj in acSSet)
{
if (acSelSetObj != null)
{
var entity = tr.GetObject(acSelSetObj.ObjectId, OpenMode.ForWrite) as Entity;
if (entity != null)
{
entity.TransformBy(Matrix3d.Scaling(0.5, pp1.Value));
}
}
}
}
tr.Commit();
}
}
}
}
}