APIで、シートメタルの展開図の折り曲げ位置のエッジ線から、山折り/谷折の情報を参照する方法

Autodesk Support

2020年11月9日


APIで、シートメタルの展開図の折り曲げ位置のエッジ線から、山折り/谷折の情報を参照する方法はありますか?

 

Solution

図面(.idw)の折り曲げ位置の線から、親となるオブジェクトを経由して元のパーツファイル(.iptファイル)のオブジェクトにアクセスし、FlatBendResult オブジェクトにアクセスすることで、折り曲げ方向の山折り/谷折りの情報を取得することができます。

次のコードは、図面(.idw)の展開図にて、選択状態にある折り曲げ位置の線から、折り曲げに関する情報を取得しメッセージボックスに表示を行います。

DrawingDocument oDoc = (DrawingDocument)m_inventorApplication.ActiveDocument;
SelectSet oSelectSet = m_inventorApplication.ActiveDocument.SelectSet;

DrawingCurveSegment oDrawingCurveSegment = null;
if( oSelectSet.Count == 1 && oSelectSet[1] is DrawingCurveSegment)
{
    oDrawingCurveSegment = (DrawingCurveSegment)oSelectSet[1];
}
else
{
    MessageBox.Show("DrawingCurveSegmentを一つ選択してください.");
    return;
}

DrawingCurve oDrawingCurve = oDrawingCurveSegment.Parent;
Edge oEdge = (Edge)oDrawingCurve.ModelGeometry;

SheetMetalComponentDefinition oSMDef = (SheetMetalComponentDefinition)oEdge.Parent.ComponentDefinition;
FlatPattern oFlatPattern = oSMDef.FlatPattern;
FlatBendResult oBendResult = (FlatBendResult)oFlatPattern.FlatBendResults[oEdge];

UnitsOfMeasure oUOM = oDoc.UnitsOfMeasure;

string message =
"---------------- Flat Bend Infos----------------\n" +
"Internal Name:{InternalName} \n" +
"Bend On {Side} Face \n" +
"Bend Angle = {Angle} \n" +
"Bend Radius = {Radius} \n" +
"Bend Direction: Bend {BendDirection} \n" +
"---------------- Flat Bend Infos----------------";

MessageBox.Show(message
    .Replace("{InternalName}", oBendResult.InternalName)
    .Replace("{Side}", oBendResult.IsOnBottomFace ? "Bottom" : "Top")
    .Replace("{Angle}", oUOM.GetStringFromValue(oBendResult.Angle, UnitsTypeEnum.kDefaultDisplayAngleUnits))
    .Replace("{Radius}", oUOM.GetStringFromValue(oBendResult.InnerRadius, UnitsTypeEnum.kDefaultDisplayLengthUnits))
    .Replace("{BendDirection}", oBendResult.IsDirectionUp ? "Up" : "Down")
);

 



この情報は役に立ちましたか?


サポートが必要な場合は、Autodesk Assistant にお問い合わせください!

Assistant が回答を見つけたり、担当者に連絡するお手伝いをします。


オートデスクではどのようなサポートが提供されますか?

ご利用可能なサポートの種類は、サブスクリプションのプランによって異なります。現在のプランでご利用可能なサポート レベルをご確認ください。

サポート レベルを確認