1

ブロック定義内の図形を直接編集するコーディング方法を教えて下さい。
例えばブロック定義内の円図形の半径を変更する、など。

過去には一度ブロックを分解して、編集、再度ブロック化といった手順で行っておりましたが、現在はブロックの分解は不要というようなお話を伺いました。

もし、サンプルコード等があればご提示いただけると助かります。

以上、よろしくお願いします。

1 件の回答 1

0

ブロック内の円を選択して、円の半径を入力した半径に変更するサンプルコードです。

public void TestCommand()
{
    var db = Application.DocumentManager.MdiActiveDocument.Database;
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    var nentres = ed.GetNestedEntity("\nSelect nested circle");
    if (nentres.Status != PromptStatus.OK) return;
    using (var tr = db.TransactionManager.StartTransaction())
    {
        foreach(var id in nentres.GetContainers())
        {
            using (var insert = tr.GetObject(id, OpenMode.ForRead) as BlockReference)
            {
                if (insert == null) continue;
                using (var circle = tr.GetObject(nentres.ObjectId, OpenMode.ForWrite) as Circle)
                {
                    if (circle == null) continue;
                    var dblopt = new PromptDoubleOptions("\nInput radius");
                    dblopt.DefaultValue = circle.Radius;
                    dblopt.UseDefaultValue = true;
                    var dblres = ed.GetDouble(dblopt);
                    if (dblres.Status != PromptStatus.OK) return;
                    circle.Radius = dblres.Value;
                }
            }
        }
        tr.Commit();
    }
    ed.Regen();
}

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。