プラグインが動作するコンテキストを定義します。具体的には、チェックするデータベースと確認に使用する標準仕様図面(DWS)ファイルを定義します。
サポートされているプラットフォーム: Windows のみ
名前空間: AcStMgr
アセンブリ: AcStMgr.tlb
VB.NET:
Public Sub SetupForAudit(pDb, szPathName, stdNameArray, stdPathArray, stdDbArray) _
Implements IAcStPlugin2.SetupForAudit
...
End Sub
C#:
public void SetupForAudit(pDb, szPathName, stdNameArray, stdPathArray, stdDbArray)
{
...;
}
タイプ: IAcStPlugin2 インタフェース
このメソッドが適用されるインタフェース。
アクセス: 入力のみ
タイプ: AcadDatabase オブジェクト
チェックする図面ファイルのデータベース オブジェクト。
アクセス: 入力のみ
タイプ: 文字列
チェックするデータベースを含んでいる図面ファイルのパスとファイル名。
アクセス: 入力のみ
タイプ: バリアント型(文字列の配列)
データベースのチェック時に使用する各標準仕様図面(DWS)の名前の配列。
アクセス: 入力のみ
タイプ: バリアント型(文字列の配列)
標準仕様図面(DWS)ファイルのパスの配列。
アクセス: 入力のみ
Type: バリアント型(AcadDatabase オブジェクトの配列)
データベースのチェック時に使用するデータベース オブジェクトの配列。
戻り値はありません。
照合するオブジェクトは、IAcStPlugin2 インタフェースの SetContext メソッドによって指定されます。これは、編集セッション中に時々変化する場合があります。
このメソッドに渡される AcadDatabase オブジェクトは、プラグインのライフタイム中は有効となるように保証されます。プラグインは、プラグインのメンバー変数にこのオブジェクトをキャッシュして、他のプラグイン メソッドからこのオブジェクトにアクセスできるようにする必要があります。
プラグインは、stdDbArray パラメータに渡される AcadDatabase オブジェクトはキャッシュするべきではありません。標準仕様のホスト アプリケーションは、繰り返し子の取得後に自由に DWS ファイルを閉じることができます。その結果、データベース オブジェクトを無効にしてしまいます。DWS ファイルからの情報を必要とするプラグインは、このメソッドで、DWS ファイルからの情報をキャッシュする必要があります(たとえば必要なデータをメモリ内のキャッシュにコピーする)。
バージョン: AutoCAD 2004 以降
VB.NET:
Public Sub SetupForAudit(ByVal pDb As AcadDatabase, _
ByVal szPathName As String, _
ByVal stdNameArray As Object, _
ByVal stdPathArray As Object, _
ByVal stdDbArray As Object) _
Implements IAcStPlugin2.SetupForAudit
' Used to define the context which the plug-in will operate.
' The drawing to be checked and the DWS files being used are passed
' to the plug-in at this point. Store the DWS standards definitions
' and the objects to be checked. The GetObjectFilter() method is used
' to specify the object type that the plug-in should check for errors.
' WARNING!: Do not save a reference to the database object,
' as it may not be valid going forward.
If Not IsNothing(pDb) Then
' Store a reference to the DWG to be checked
m_pCheckDatabase = pDb
' Verify the reference to the DWG is valid object
If Not IsNothing(m_pCheckDatabase) Then
' << Change based on standards implementation >>
For Each acObj As AcadObject In m_pCheckDatabase.Layers
If acObj.ObjectName = "AcDbLayerTableRecord" Then
m_ContextList.Add(acObj.ObjectID, True)
End If
Next
End If
Dim iDWS As Integer
' Iterate each of the DWS files and cache the objects to use to fix errors
For iDWS = 0 To UBound(stdDbArray)
' Get the DWS database
m_pDWSDatabase = stdDbArray(iDWS)
' << Change based on standards implementation >>
Dim pStdLayer As AcadLayer
' Iterate the layers in the database
Dim i As Integer = 0
For Each pStdLayer In m_pDWSDatabase.Layers
Dim layerCache As New LayerCache()
' Cache the properties of the layers in the DWS database
layerCache.Name = pStdLayer.Name
layerCache.Color = pStdLayer.color
layerCache.Lineweight = pStdLayer.Lineweight
layerCache.StandardFileName = stdNameArray(iDWS)
' Create a fix object to be used later to correct a standards violation
Dim pFix As New AcStFix()
pFix.Description = "Layer fix"
pFix.StandardFileName = layerCache.StandardFileName
pFix.FixObjectName = pStdLayer.Name
If pFix.PropertyCount = 0 Then
pFix.PropertyValuePut("Color", pStdLayer.color)
pFix.PropertyValuePut("Lineweight", pStdLayer.Lineweight)
End If
layerCache.StandardsFix = pFix
ReDim Preserve m_LayerCacheArray(i)
m_LayerCacheArray(i) = layerCache
layerCache = Nothing
pFix = Nothing
i = i + 1
Next
m_pDWSDatabase = Nothing
Next
End If
End Sub
C#:
public void SetupForAudit(AcadDatabase pDb, string szPathName, object stdNameArray,
object stdPathArray, object stdDbArray)
{
// Used to define the context which the plug-in will operate.
// The drawing to be checked and the DWS files being used are passed
// to the plug-in at this point. Store the DWS standards definitions
// and the objects to be checked. The GetObjectFilter() method is used
// to specify the object type that the plug-in should check for errors.
// WARNING!: Do not save a reference to the database object,
// as it may not be valid going forward.
if (pDb != null)
{
// Store a reference to the DWG to be checked
m_pCheckDatabase = pDb;
// Verify the reference to the DWG is valid object
if ((m_pCheckDatabase != null))
{
// << Change based on standards implementation >>
foreach (AcadObject acObj in m_pCheckDatabase.Layers)
{
if (acObj.ObjectName == "AcDbLayerTableRecord")
{
m_ContextList.Add(acObj.ObjectID, true);
}
}
}
int i = 0;
int iDWS = 0;
int nLBound = ((Array)stdDbArray).GetLowerBound(0);
int nUBound = ((Array)stdDbArray).GetUpperBound(0);
// Iterate each of the DWS files and cache the objects to use to fix errors
for (iDWS = 0; iDWS <= nUBound; iDWS++)
{
// Get the DWS database
m_pDWSDatabase = (AcadDatabase)((Array)stdDbArray).GetValue(iDWS);
// << Change based on standards implementation >>
// Iterate the layers in the database
foreach (AcadLayer pStdLayer in m_pDWSDatabase.Layers)
{
AdskLayersPlugin.StandardsHelpers.LayerCache oLayerCache = new AdskLayersPlugin.StandardsHelpers.LayerCache();
// Cache the properties of the layers in the DWS database
oLayerCache.Name = pStdLayer.Name;
oLayerCache.Color = (ACAD_COLOR)pStdLayer.color;
oLayerCache.Lineweight = (ACAD_LWEIGHT)pStdLayer.Lineweight;
oLayerCache.StandardFileName = (String)((Array)stdNameArray).GetValue(iDWS);
oLayerCache.ObjectId = pStdLayer.ObjectID;
// Create a fix object to be used later to correct a standards violation
AcStFix pFix = new AcStFix();
pFix.Description = "Layer fix";
pFix.StandardFileName = oLayerCache.StandardFileName;
pFix.FixObjectName = pStdLayer.Name;
pFix.FixObjectId = oLayerCache.ObjectId;
if (pFix.PropertyCount == 0)
{
pFix.PropertyValuePut("Color", (ACAD_COLOR)pStdLayer.color);
pFix.PropertyValuePut("Lineweight", (ACAD_LWEIGHT)pStdLayer.Lineweight);
}
oLayerCache.StandardsFix = pFix;
Array.Resize(ref m_LayerCacheArray, i + 1);
m_LayerCacheArray[i] = oLayerCache;
oLayerCache = null;
pFix = null;
i = i + 1;
}
m_pDWSDatabase = null;
}
}
}