如何更新一个2014的C#?NET到2020版?
我需要更新一个旧的2014 VB.net,将图纸集重新编号为Autocad 2020。我使用的是VS 2017和VS 2019。
原始帖子:
http://www.theswamp.org/index.php?topic=45672.msg508180#msg508180
这是我的版本:
// (C) Copyright 2019 by
//
//using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
///tlbimp acsmcomponents19.tlb /out:Interop.ACSMCOMPONENTS19Lib.dll/namespace:AcSm/machine:x64
///tlbimp acsmcomponents23.tlb /out:Interop.ACSMCOMPONENTS23Lib.dll/namespace:AcSm/machine:x64
///"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe" "C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\acsmcomponents23.tlb" /out:"C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\Interop.ACSMCOMPONENTS23Lib.dll"/namespace:AcSm/machine:x64
///*
///* SheetSetTools. © Andrey Bushman, 2013
///* AutoCAD 2014 x64 Enu
///*
///* COMMANDS:
///* SS-RENUMBER-ALL - Update the numeration for all sheets in the all opened sheet sets:
///* numbering of each subgroup shall begin with 1.
///*
///* SS-RENUMBER-ALL-BASES-OF-FIRST - Update the numeration: to continue numbering on the
///* basis of the first element in the each subset (in the all opened sheet sets).
///*
///* AutoCAD references:
///* AcCoreMgd.dll
///* AcDbMgd.dll
///* AcMgd.dll
///* Interop.ACSMCOMPONENTS23Lib.dll
///*/
using System;
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using App = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Rtm = Autodesk.AutoCAD.Runtime;
using Comp = ACSMCOMPONENTS23Lib;
namespace Bushman.AutoCAD.SheetSetTools
{
public class SheetSetCommands : Rtm.IExtensionApplication
{
const String ns = "bush"; // namespace
///
/// Update the numeration for all sheets in the all opened sheet sets: numbering of
/// each subgroup shall begin with 1.
///
public void Renumber_All()
{
Renumber();
}
///
/// Update the numeration: to continue numbering on the basis of the first element
/// in the each subset (in the all opened sheet sets).
///
public void Renumber_all_bases_of_first()
{
Renumber(true);
}
///
/// To update numbering of all sheets in the all opened sheet sets.
///
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void Renumber(Boolean continue_numbering = false)
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Db.Database db = doc.Database;
Ed.Editor ed = doc.Editor;
Comp.AcSmSheetSetMgr mng = new Comp.AcSmSheetSetMgr();
Comp.IAcSmEnumDatabase enumerator = mng.GetDatabaseEnumerator();
enumerator.Reset();
Comp.AcSmDatabase smDb = null;
while ((smDb = enumerator.Next()) != null)
{
smDb.LockDb(db);
String fname = smDb.GetFileName();
Comp.AcSmSheetSet sheetset = smDb.GetSheetSet();
String name = sheetset.GetName();
String descr = sheetset.GetDesc();
ed.WriteMessage("\nSheet Set name: {0}\n", name);
Int32 ren_count = 0; // count of renamed sheets.
Comp.IAcSmEnumComponent encomp = sheetset.GetSheetEnumerator();
encomp.Reset();
Comp.IAcSmComponent component = null;
while ((component = encomp.Next()) != null)
{
ProcessElement(ed, component, ref ren_count, continue_numbering);
}
encomp.Reset();
smDb.UnlockDb(db, true);
ed.WriteMessage("Renumbered sheets count: {0}\n", ren_count);
}
enumerator.Reset();
}
///
///Recursive processing of the elements: change the sheet's number.
///
/// An Editor for the output.
/// Component of Sheet Set.
/// The count of renumbered sheets in the sheet set.
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void ProcessElement(Ed.Editor ed, Comp.IAcSmComponent component,
ref Int32 ren_count, Boolean continue_numbering)
{
Array array = null;
component.GetDirectlyOwnedObjects(out array);
if (array != null)
{
Int32 sheet_number = 1;
Boolean basis_of_first = continue_numbering;
foreach (var item in array)
{
if (item is Comp.IAcSmSubset)
{
ProcessElement(ed, (Comp.IAcSmSubset)item, ref ren_count, continue_numbering);
}
else if (item is Comp.IAcSmSheet)
{
Comp.IAcSmSheet sheet = (Comp.IAcSmSheet)item;
String cur_str_value = sheet.GetNumber();
Int32 int_value = 0;
Boolean is_int32 = Int32.TryParse(cur_str_value, out int_value);
if (!is_int32 || (!basis_of_first && int_value != sheet_number))
{
sheet.SetNumber(sheet_number.ToString());
++ren_count;
}
else if (basis_of_first)
{
sheet_number = int_value;
}
++sheet_number;
basis_of_first = false;
}
else if (item is Comp.IAcSmPersist)
{
Comp.IAcSmPersist persist = (Comp.IAcSmPersist)item;
}
else
{
ed.WriteMessage("Unknown object: {0}", item.GetType().ToString());
}
}
}
}
#region IExtensionApplication Members
public void Initialize()
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Ed.Editor ed = doc.Editor;
ed.WriteMessage("\nSheetSetTools. © Andrey Bushman, 2013\n\n");
}
public void Terminate()
{
// Empty body.
}
#endregion
}
}
那么,我该怎么做呢?(如有可能,请逐项解释)
**** Hidden Message *****
究竟有哪些错误?
您知道您进行了哪些更改以及为什么进行了更改吗?
有哪些错误..确实如此。
您知道自己做了哪些更改以及为什么要做这些更改吗?
我将“ACSMCOMPONENTS19Lib”改为“ACSMCOMPONENTS23Lib”,因为在另一篇文章中推荐了。
根据岗位需要换成用这个旧的。NET在AutoCAD 2020中的应用。
POST:
https://forums . Autodesk . com/t5/visual-lisp-AutoLISP-and-general/add-the-reference-quot-interop-acsmcomponents 19 lib-dll-quot/m-p/8743453/highlight/true # m 384092
my questions:
3 Where can I get the ObjectARX 2020 SDK?
4 Should I change all texts "Interop.ACSMCOMPONENTS19Lib.dll" for "Interop.ACSMCOMPONENTS23Lib.dll" inside the code?
his answer:
3. here.
4. Yes for sure.
错误代码2]
我已经用
C:\Windows\system32>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe" "C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\acsmcomponents23.tlb" /out:"Interop.ACSMCOMPONENTS23Lib.dll"/namespace:AcSm/machine:x64
Microsoft (R) .NET Framework Type Library to Assembly Converter 4.8.3761.0 Copyright (C) Microsoft Corporation.All rights reserved.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.IAcSmFiler.ReadRawData' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.IAcSmFiler.ReadBytes' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : warning TI3019 : Interface 'IAcadShadowDisplay' is marked as , but does not derive from IDispatch. It will be converted as an IUnknown-derived interface.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.IAcSmPersistProxy.GetRawData' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.AcSmDSTFilerClass.ReadRawData' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.AcSmDSTFilerClass.ReadBytes' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : warning TI3015 : At least one of the arguments for 'AcSm.AcSmPersistProxyClass.GetRawData' cannot be marshaled by the runtime marshaler.Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
TlbImp : Type library imported to C:\Windows\system32\Interop.ACSMCOMPONENTS23Lib.dll
错误是什么...到底?
你知道你做了什么更改以及为什么要做这些更改吗?
我使用了这篇文章中建议的命令:
https://forums.autodesk.com/t5/objectarx/objectarx-for-autocad-2013/m-p/8743364#M38516
tlbimp acsmcomponents23.tlb /out:Interop.ACSMCOMPONENTS23Lib.dll /namespace:AcSm /machine:x64
我不知道
你为什么需要这样做..我把这个直接从盒子里拿出来....
也许你需要问亚历山大...但是你确实在ObjectARX论坛上问过他,他有理由相信你想要ARX应用程序的功能。
您的 VS C# 引用是否看起来像这样??
安德烈的代码有几个版本…没有你最近发布的miriad版本
你知道你从哪里得到你正在使用的版本吗
我不知道你为什么要这么做...我直接开箱即用......
也许你需要问亚历山大...但是你确实在ObjectARX论坛上问过他,他有理由相信你想要ARX应用程序的功能。
您的VS C#引用看起来像这样吗??
感谢您的帮助朋友...
我还有一个错误:
Severity Code Description Project File Line Suppression State
Error CS0579 Duplicate 'Rtm.ExtensionApplication' attribute ss-renumber2 C:\Users\JuanJ\source\repos\ss-renumber-solution2\ss-renumber2\Class1.cs 32 Active
这里:
我不确定在这里做什么。
…这是我正在编写的代码,我不确定是否正确地将ACSMCOMPONENTS19Lib更改为ACSMCompoonets23lib:
///tlbimp acsmcomponents19.tlb /out:Interop.ACSMCOMPONENTS19Lib.dll/namespace:AcSm/machine:x64
///tlbimp acsmcomponents23.tlb /out:Interop.ACSMCOMPONENTS23Lib.dll/namespace:AcSm/machine:x64
///"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe" "C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\acsmcomponents23.tlb" /out:"C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\Interop.ACSMCOMPONENTS23Lib.dll"/namespace:AcSm/machine:x64
///"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe" "C:\Autodesk\ObjectARX_for_AutoCAD_2020_Win_64_bit\inc-x64\acsmcomponents23.tlb" /out:"Interop.ACSMCOMPONENTS23Lib.dll"/namespace:AcSm/machine:x64
/*
* SheetSetTools. © Andrey Bushman, 2013
* AutoCAD 2014 x64 Enu
*
* COMMANDS:
* SS-RENUMBER-ALL - Update the numeration for all sheets in the all opened sheet sets:
* numbering of each subgroup shall begin with 1.
*
* SS-RENUMBER-ALL-BASES-OF-FIRST - Update the numeration: to continue numbering on the
* basis of the first element in the each subset (in the all opened sheet sets).
*
* AutoCAD references:
* AcCoreMgd.dll
* AcDbMgd.dll
* AcMgd.dll
* Interop.ACSMCOMPONENTS23Lib.dll
*/
using System;
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using App = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Rtm = Autodesk.AutoCAD.Runtime;
using Comp = ACSMCOMPONENTS23Lib;
namespace Bushman.AutoCAD.SheetSetTools
{
public class SheetSetCommands : Rtm.IExtensionApplication
{
const String ns = "bush"; // namespace
///
/// Update the numeration for all sheets in the all opened sheet sets: numbering of
/// each subgroup shall begin with 1.
///
public void Renumber_All()
{
Renumber();
}
///
/// Update the numeration: to continue numbering on the basis of the first element
/// in the each subset (in the all opened sheet sets).
///
public void Renumber_all_bases_of_first()
{
Renumber(true);
}
///
/// To update numbering of all sheets in the all opened sheet sets.
///
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void Renumber(Boolean continue_numbering = false)
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Db.Database db = doc.Database;
Ed.Editor ed = doc.Editor;
Comp.AcSmSheetSetMgr mng = new Comp.AcSmSheetSetMgr();
Comp.IAcSmEnumDatabase enumerator = mng.GetDatabaseEnumerator();
enumerator.Reset();
Comp.AcSmDatabase smDb = null;
while ((smDb = enumerator.Next()) != null)
{
smDb.LockDb(db);
String fname = smDb.GetFileName();
Comp.AcSmSheetSet sheetset = smDb.GetSheetSet();
String name = sheetset.GetName();
String descr = sheetset.GetDesc();
ed.WriteMessage("\nSheet Set name: {0}\n", name);
Int32 ren_count = 0; // count of renamed sheets.
Comp.IAcSmEnumComponent encomp = sheetset.GetSheetEnumerator();
encomp.Reset();
Comp.IAcSmComponent component = null;
while ((component = encomp.Next()) != null)
{
ProcessElement(ed, component, ref ren_count, continue_numbering);
}
encomp.Reset();
smDb.UnlockDb(db, true);
ed.WriteMessage("Renumbered sheets count: {0}\n", ren_count);
}
enumerator.Reset();
}
///
///Recursive processing of the elements: change the sheet's number.
///
/// An Editor for the output.
/// Component of Sheet Set.
/// The count of renumbered sheets in the sheet set.
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void ProcessElement(Ed.Editor ed, Comp.IAcSmComponent component,
ref Int32 ren_count, Boolean continue_numbering)
{
Array array = null;
component.GetDirectlyOwnedObjects(out array);
if (array != null)
{
Int32 sheet_number = 1;
Boolean basis_of_first = continue_numbering;
foreach (var item in array)
{
if (item is Comp.IAcSmSubset)
{
ProcessElement(ed, (Comp.IAcSmSubset)item, ref ren_count, continue_numbering);
}
else if (item is Comp.IAcSmSheet)
{
Comp.IAcSmSheet sheet = (Comp.IAcSmSheet)item;
String cur_str_value = sheet.GetNumber();
Int32 int_value = 0;
Boolean is_int32 = Int32.TryParse(cur_str_value, out int_value);
if (!is_int32 || (!basis_of_first && int_value != sheet_number))
{
sheet.SetNumber(sheet_number.ToString());
++ren_count;
}
else if (basis_of_first)
{
sheet_number = int_value;
}
++sheet_number;
basis_of_first = false;
}
else if (item is Comp.IAcSmPersist)
{
Comp.IAcSmPersist persist = (Comp.IAcSmPersist)item;
}
else
{
ed.WriteMessage("Unknown object: {0}", item.GetType().ToString());
}
}
}
}
#region IExtensionApplication Members
public void Initialize()
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Ed.Editor ed = doc.Editor;
ed.WriteMessage("\nSheetSetTools. © Andrey Bushman, 2013\n\n");
}
public void Terminate()
{
// Empty body.
}
#endregion
}
}
…我解决了重复的问题
但是现在我构建了DLL文件,但是SS-renumber-all和SS-reumber-all-BASES-OF-FIRST不起作用
/// Update the numeration for all sheets in the all opened sheet sets: numbering of
/// each subgroup shall begin with 1.
///
public void Renumber_All()
{
Renumber();
}
///
/// Update the numeration: to continue numbering on the basis of the first element
/// in the each subset (in the all opened sheet sets).
///
public void Renumber_all_bases_of_first()
{
Renumber(true);
}
///
/// To update numbering of all sheets in the all opened sheet sets.
///
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void Renumber(Boolean continue_numbering = false)
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Db.Database db = doc.Database;
Ed.Editor ed = doc.Editor;
Comp.AcSmSheetSetMgr mng = new Comp.AcSmSheetSetMgr();
Comp.IAcSmEnumDatabase enumerator = mng.GetDatabaseEnumerator();
enumerator.Reset();
Comp.AcSmDatabase smDb = null;
while ((smDb = enumerator.Next()) != null)
{
smDb.LockDb(db);
String fname = smDb.GetFileName();
Comp.AcSmSheetSet sheetset = smDb.GetSheetSet();
String name = sheetset.GetName();
String descr = sheetset.GetDesc();
ed.WriteMessage("\nSheet Set name: {0}\n", name);
Int32 ren_count = 0; // count of renamed sheets.
Comp.IAcSmEnumComponent encomp = sheetset.GetSheetEnumerator();
encomp.Reset();
Comp.IAcSmComponent component = null;
while ((component = encomp.Next()) != null)
{
ProcessElement(ed, component, ref ren_count, continue_numbering);
}
encomp.Reset();
smDb.UnlockDb(db, true);
ed.WriteMessage("Renumbered sheets count: {0}\n", ren_count);
}
enumerator.Reset();
}
///
///Recursive processing of the elements: change the sheet's number.
///
/// An Editor for the output.
/// Component of Sheet Set.
/// The count of renumbered sheets in the sheet set.
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void ProcessElement(Ed.Editor ed, Comp.IAcSmComponent component,
ref Int32 ren_count, Boolean continue_numbering)
{
Array array = null;
component.GetDirectlyOwnedObjects(out array);
if (array != null)
{
Int32 sheet_number = 1;
Boolean basis_of_first = continue_numbering;
foreach (var item in array)
{
if (item is Comp.IAcSmSubset)
{
ProcessElement(ed, (Comp.IAcSmSubset)item, ref ren_count, continue_numbering);
}
else if (item is Comp.IAcSmSheet)
{
Comp.IAcSmSheet sheet = (Comp.IAcSmSheet)item;
String cur_str_value = sheet.GetNumber();
Int32 int_value = 0;
Boolean is_int32 = Int32.TryParse(cur_str_value, out int_value);
if (!is_int32 || (!basis_of_first && int_value != sheet_number))
{
sheet.SetNumber(sheet_number.ToString());
++ren_count;
}
else if (basis_of_first)
{
sheet_number = int_value;
}
++sheet_number;
basis_of_first = false;
}
else if (item is Comp.IAcSmPersist)
{
Comp.IAcSmPersist persist = (Comp.IAcSmPersist)item;
}
else
{
ed.WriteMessage("Unknown object: {0}", item.GetType().ToString());
}
}
}
}
#region IExtensionApplication Members
public void Initialize()
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Ed.Editor ed = doc.Editor;
ed.WriteMessage("\nSheetSetTools. © Andrey Bushman, 2013\n\n");
}
public void Terminate()
{
// Empty body.
}
#endregion
}
}
这个代码有最小的修改,但现在我在VS 2017中有4个“消息”:
Severity Code Description Project File Line Suppression State
Message IDE0018 Variable declaration can be inlined ss-renumber2 C:\Users\JuanJ\source\repos\ss-renumber-solution2\ss-renumber2\myCommands.cs 127 Active
Message IDE0018 Variable declaration can be inlined ss-renumber2 C:\Users\JuanJ\source\repos\ss-renumber-solution2\ss-renumber2\myCommands.cs 110 Active
Message IDE0020 Use pattern matching ss-renumber2 C:\Users\JuanJ\source\repos\ss-renumber-solution2\ss-renumber2\myCommands.cs 124 Active
Message IDE0020 Use pattern matching ss-renumber2 C:\Users\JuanJ\source\repos\ss-renumber-solution2\ss-renumber2\myCommands.cs 144 Active
我不确定这是否是正确的方式,但也许我节省了一点你的时间。 之后,VS自动解决此类消息,获得此代码:
/*
* SheetSetTools. © Andrey Bushman, 2013
* AutoCAD 2014 x64 Enu
*
* COMMANDS:
* SS-RENUMBER-ALL - Update the numeration for all sheets in the all opened sheet sets:
* numbering of each subgroup shall begin with 1.
*
* SS-RENUMBER-ALL-BASES-OF-FIRST - Update the numeration: to continue numbering on the
* basis of the first element in the each subset (in the all opened sheet sets).
*
* AutoCAD references:
* AcCoreMgd.dll
* AcDbMgd.dll
* AcMgd.dll
* Interop.ACSMCOMPONENTS23Lib.dll
*/
using System;
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using App = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Rtm = Autodesk.AutoCAD.Runtime;
using Comp = ACSMCOMPONENTS23Lib;
namespace Bushman.AutoCAD.SheetSetTools
{
public class SheetSetCommands : Rtm.IExtensionApplication
{
const String ns = "bush"; // namespace
///
/// Update the numeration for all sheets in the all opened sheet sets: numbering of
/// each subgroup shall begin with 1.
///
public void Renumber_All()
{
Renumber();
}
///
/// Update the numeration: to continue numbering on the basis of the first element
/// in the each subset (in the all opened sheet sets).
///
public void Renumber_all_bases_of_first()
{
Renumber(true);
}
///
/// To update numbering of all sheets in the all opened sheet sets.
///
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void Renumber(Boolean continue_numbering = false)
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Db.Database db = doc.Database;
Ed.Editor ed = doc.Editor;
Comp.AcSmSheetSetMgr mng = new Comp.AcSmSheetSetMgr();
Comp.IAcSmEnumDatabase enumerator = mng.GetDatabaseEnumerator();
enumerator.Reset();
Comp.AcSmDatabase smDb = null;
while ((smDb = enumerator.Next()) != null)
{
smDb.LockDb(db);
String fname = smDb.GetFileName();
Comp.AcSmSheetSet sheetset = smDb.GetSheetSet();
String name = sheetset.GetName();
String descr = sheetset.GetDesc();
ed.WriteMessage("\nSheet Set name: {0}\n", name);
Int32 ren_count = 0; // count of renamed sheets.
Comp.IAcSmEnumComponent encomp = sheetset.GetSheetEnumerator();
encomp.Reset();
Comp.IAcSmComponent component = null;
while ((component = encomp.Next()) != null)
{
ProcessElement(ed, component, ref ren_count, continue_numbering);
}
encomp.Reset();
smDb.UnlockDb(db, true);
ed.WriteMessage("Renumbered sheets count: {0}\n", ren_count);
}
enumerator.Reset();
}
///
///Recursive processing of the elements: change the sheet's number.
///
/// An Editor for the output.
/// Component of Sheet Set.
/// The count of renumbered sheets in the sheet set.
/// True - to continue numbering on the basis
/// of the first element in the each subset (in the all opened sheet sets);
/// False - Numbering of each subgroup shall begin with 1 (in the all opened
/// sheet sets).
void ProcessElement(Ed.Editor ed, Comp.IAcSmComponent component,
ref Int32 ren_count, Boolean continue_numbering)
{
component.GetDirectlyOwnedObjects(out Array array);
if (array != null)
{
Int32 sheet_number = 1;
Boolean basis_of_first = continue_numbering;
foreach (var item in array)
{
if (item is Comp.IAcSmSubset)
{
ProcessElement(ed, (Comp.IAcSmSubset)item, ref ren_count, continue_numbering);
}
else if (item is Comp.IAcSmSheet sheet)
{
String cur_str_value = sheet.GetNumber();
Boolean is_int32 = Int32.TryParse(cur_str_value, out int int_value);
if (!is_int32 || (!basis_of_first && int_value != sheet_number))
{
sheet.SetNumber(sheet_number.ToString());
++ren_count;
}
else if (basis_of_first)
{
sheet_number = int_value;
}
++sheet_number;
basis_of_first = false;
}
else if (item is Comp.IAcSmPersist persist)
{
}
else
{
ed.WriteMessage("Unknown object: {0}", item.GetType().ToString());
}
}
}
}
#region IExtensionApplication Members
public void Initialize()
{
App.Document doc = cad.DocumentManager.MdiActiveDocument;
Ed.Editor ed = doc.Editor;
ed.WriteMessage("\nSheetSetTools. © Andrey Bushman, 2013\n\n");
}
public void Terminate()
{
// Empty body.
}
#endregion
}
}
当我尝试“开始调试”时,只是打开了Autocad 2020,但键入命令“SS-RENUMBER-ALL”和“SS-RENUMBER-ALL-BASES-OF-FIRST”却什么也没做,并且不显示这样的命令加载...
...但是当我按下“构建”并使用NETLOAD。DLL "文件,然后加载没有问题和键入命令我有一个响应:
“SS-全部重新编号”和“SS-首先重新编号-所有基数”根本不起作用,那么,我现在该怎么办?
页:
[1]
2