SetupForAudit 方法 (ActiveX/CSP)
定义插件将在其中运行的上下文,特别是要检查的数据库和将用于检查的图形标准 (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) { ...; }
返回值 (RetVal)无返回值。 言论要检查的对象由接口的方法指定。在编辑会话期间,它可能会不时变化。SetContextIAcStPlugin2 传递给此方法的对象保证在插件的生存期内有效。插件应将此对象缓存在插件的成员变量中,以允许从其他插件方法访问对象。AcadDatabase 插件不应缓存传递给 stdDbArray 参数的对象。标准主机应用程序在获取迭代器后可以自由关闭DWS文件,从而使数据库对象失效。需要DWS文件中信息的插件应使用此方法缓存来自DWS文件的信息,例如将必要的数据复制到内存中缓存。AcadDatabase 发行信息释放: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; } } } |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-16 00:09
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.