C# プラグインでオフセット コマンドを使用するにはどうすればよいですか? オフセットとオフセット値に含めるライン/アークのリストがあります。使用するコマンドが見つかりません。
クラスにはそれを行うための何かが含まれていると思ってElementTransformUnit
いましたが、そうではないようです...
ありがとうございました
私が知っている Offset コマンドはありませんが、ElementTransformUtils.CopyElement
代わりにメソッドを使用してかなり簡単に作成できると思います。次のようなことを試してください:
static ElementId Offset(this Element originalelement, double offsetamount, string offsetdirection)
{
ElementId newelement = null;
Document curdoc = originalelement.Document;
LocationPoint elp = originalelement.Location as LocationPoint;
XYZ elem_location = null;
switch(offsetdirection.ToUpper())
{
default:
break;
case "X":
elem_location = new XYZ(offsetamount, 0.0, 0.0) + elp.Point;
break;
case "Y":
// code for Y
break;
case "Z":
// code for Z
break;
}
try
{
using (Transaction tr_offset = new Transaction(curdoc, "Offsetting element"))
{
tr_offset.Start();
newelement = ElementTransformUtils.CopyElement(curdoc, originalelement.Id, elem_location).FirstOrDefault();
tr_offset.Commit();
}
}
catch (Exception e)
{
Console.WriteLine("Command Failed. See below: \n" + e.StackTrace.ToString());
}
return newelement;
}
Direction 列挙型などを作成した方が良いかもしれませんが、それはあなたの目的には合っているはずです。