VisualStudio代码片段配置
2025年1月5日小于 1 分钟
在下面的路径新增一个.snippet
文件,写入内容,重启VS
C:\Program Files\Microsoft Visual Studio\2022\Community\VC#\Snippets\1033\Visual C#
Revit外部事件
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>revitTask</Title>
<Shortcut>rta</Shortcut>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>Revit.Async</Namespace>
</Import>
</Imports>
<Code Language="csharp"><![CDATA[
RevitTask.RunAsync((app) =>
{
var uidoc = app.ActiveUIDocument;
var doc = uidoc.Document;
$selected$ $end$
});
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Cad报错日志
想要显示$
,需用用两个
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>errlog</Title>
<Shortcut>errlog</Shortcut>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>IFoxCAD.Cad</Namespace>
</Import>
<Import>
<Namespace>CSEC8BCADSiteLayout.Common</Namespace>
</Import>
</Imports>
<Code Language="csharp"><![CDATA[Env.Printl($$"操作失败,报错消息:{ex.Message}");
Log4NetUtls.Error(ex.Message);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>