Defines the context in which a plug-in will operate, specifically the database to check and the drawing standards (DWS) files that will be used for checking.
Supported platforms: Windows only
Namespace: AcStMgr
Assembly: 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) { ...; }
Type: IAcStPlugin2 interface
The interface this method applies to.
Access: Input-only
Type: AcadDatabase object
The database object of the drawing file to check.
Access: Input-only
Type: String
The path and file name of the drawing file that contains the database to check.
Access: Input-only
Type: Variant (Array of Strings)
The array of names for each standards drawing (DWS) files to use when checking the database.
Access: Input-only
Type: Variant (Array of Strings)
The array of paths for the standards drawing (DWS) files.
Access: Input-only
Type: Variant (Array ofAcadDatabase objects)
The array of database objects to use when checking the database.
No return value.
The objects to check against is specified in by the SetContext method of the IAcStPlugin2 interface. It may vary from time to time during an editing session.
The AcadDatabase object passed to this method is guaranteed to be valid for the lifetime of the plug-in. Plug-ins should cache this object in a member variable of the plug-in to allow access to the objects from other plug-in methods.
Plug-ins should not cache the AcadDatabase objects passed to the stdDbArray parameter. The standards host application is free to close the DWS files after obtaining an iterator, thereby invalidating the database objects. Plug-ins that need information from the DWS files should cache information from them with this method, for example by copying the necessary data to an in-memory cache.
Releases: AutoCAD 2004 and later
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; } } }