diff --git a/.gitignore b/.gitignore index 3e8a1553fcff7845c779d3cb8014e151a9931506..faf876255f879578e1407606fc89f5473b4d3eee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## 忽略Visual Studio临时文件、生成结果和由VisualStudio常用插件生成的文件。 ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files +# 用户特定文件 *.rsuser *.suo *.user @@ -11,9 +13,12 @@ *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) +# 用户特定文件 (MonoDevelop/Xamarin Studio) *.userprefs # Build results +# Build 结果 +# 语法:[abc]匹配任何一个列在方括号中的字符(要么匹配一个 a,要么匹配一个 b,要么匹配一个 c)——如 *.[oa]表明Git忽略所有以 .o 或 .a 结尾的文件 [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ @@ -28,27 +33,34 @@ bld/ [Ll]og/ # Visual Studio 2015/2017 cache/options directory +# Visual Studio 2015/2017 缓存/选项 目录 .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot +# 如果您有在wwwroot中创建项目静态文件的任务,请取消注释 #wwwroot/ # Visual Studio 2017 auto generated files +# Visual Studio 2017自动生成的文件 Generated\ Files/ # MSTest test Results +# MSTest测试结果 [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT +# NUnit 是 JUnit 的 .NET 版,支持所有 .NET 语言,完全使用 C# 编写,并进行完全重新设计以利用很多高级的 .NET 语言特性,例如定制属性以及其他相关的反射功能。 *.VisualState.xml TestResult.xml # Build Results of an ATL Project +# ATL项目的生成结果 [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results +# Benchmark结果 BenchmarkDotNet.Artifacts/ # .NET Core @@ -57,9 +69,11 @@ project.fragment.lock.json artifacts/ # StyleCop +# 代码检测工具 StyleCopReport.xml # Files built by Visual Studio +# Visual Studio built的文件 *_i.c *_p.c *_h.h @@ -89,9 +103,11 @@ StyleCopReport.xml *.scc # Chutzpah Test files +# Chutzpah测试文件 _Chutzpah* # Visual C++ cache files +# Visual C++ 缓存文件 ipch/ *.aps *.ncb @@ -103,18 +119,23 @@ ipch/ *.VC.VC.opendb # Visual Studio profiler +# 应用程序性能分析工具 *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files +# Visual Studio 跟踪文件 *.e2e # TFS 2012 Local Workspace +# TFS 2012 本地工作区 $tf/ # Guidance Automation Toolkit +# 这套工具旨在简化将可重用的代码集成到应用程序的过程,使架构师能将通常需手动执行的一系列开发工作自动化起来。 +# 使用此工具,还能确保重复性的、易出错的开发工作以合理、一致的方式完成,并能缩短软件开发时间。 *.gpState # ReSharper is a .NET coding add-in @@ -152,9 +173,11 @@ AutoTest.Net/ .sass-cache/ # Installshield output folder +# Installshield 输出文件夹 [Ee]xpress/ # DocProject is a documentation generator add-in +# DocProject 是一个文档生成器外接程序 DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC @@ -172,23 +195,32 @@ publish/ *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted +# 注意:如果要签入web部署设置,请在下一行添加注释, +# 但是数据库连接字符串(带有可能的密码)将是未加密的 *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted +# Microsoft Azure Web App发布设置。 +# 如果您想签入Azure Web App发布设置,请在下一行添加注释,但这些脚本中包含的敏感信息将不加密 PublishScripts/ # NuGet Packages +# NuGet包 *.nupkg # The packages folder can be ignored because of Package Restore +# 由于Package Restore,包文件夹可以忽略 **/[Pp]ackages/* # except build/, which is used as an MSBuild target. +# 除了build/,它用作MSBuild目标。 !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed +# 必要时取消注释,但通常需要时会重新生成注释 #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files +# NuGet v3的project.json文件生成更多可忽略的文件 *.nuget.props *.nuget.targets @@ -201,6 +233,7 @@ ecf/ rcf/ # Windows Store app package directories and files +# Windows应用商店应用程序包目录和文件 AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml @@ -208,12 +241,16 @@ _pkginfo.txt *.appx # Visual Studio cache files +# Visual Studio缓存文件 # files ending in .cache can be ignored +# 可以忽略以.cache结尾的文件 *.[Cc]ache # but keep track of directories ending in .cache +# 但要跟踪以.cache结尾的目录 !?*.[Cc]ache/ # Others +# 其他 ClientBin/ ~$* *~ @@ -225,13 +262,16 @@ ClientBin/ orleans.codegen.cs # Including strong name files can present a security risk +# 包含强名称文件可能会带来安全风险 # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components +#由于有多个工作流,取消注释下一行以忽略bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +#ASP.NET核心默认设置:bower目录配置为wwwroot/lib/并且bower restore为true **/wwwroot/lib/ # RIA/Silverlight projects @@ -240,6 +280,7 @@ Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) +#将旧项目文件转换为新的Visual Studio版本的备份和报告文件。不需要备份文件,因为我们有git; _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML @@ -253,6 +294,7 @@ ServiceFabricBackup/ *.ndf # Business Intelligence projects +# 商业智能项目 *.rdl.data *.bim.layout *.bim_*.settings @@ -262,22 +304,28 @@ ServiceFabricBackup/ FakesAssemblies/ # GhostDoc plugin setting file +# GhostDoc插件设置文件 *.GhostDoc.xml # Node.js Tools for Visual Studio +# 用于Visual Studio的Node.js工具 .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log +# Visual Studio 6生成日志 *.plg # Visual Studio 6 workspace options file +# Visual Studio 6工作区选项文件 *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +# Visual Studio 6自动生成的工作区文件(包含打开的文件等) *.vbw # Visual Studio LightSwitch build output +# Visual Studio LightSwitch生成输出 **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml @@ -286,6 +334,7 @@ node_modules/ _Pvt_Extensions # Paket dependency manager +# Paket依赖关系管理器 .paket/paket.exe paket-files/ @@ -304,6 +353,7 @@ __pycache__/ *.pyc # Cake - Uncomment if you are using it +# Cake-如果你正在使用它,请取消注释 # tools/** # !tools/packages.config @@ -311,8 +361,10 @@ __pycache__/ *.tss # Telerik's JustMock configuration file +# Telerik的JustMock配置文件 *.jmconfig +# BizTalk build output # BizTalk build output *.btp.cs *.btm.cs @@ -320,22 +372,29 @@ __pycache__/ *.xsd.cs # OpenCover UI analysis results +# OpenCover UI分析结果 OpenCover/ # Azure Stream Analytics local run output +# Azure流分析本地运行输出 ASALocalRun/ # MSBuild Binary and Structured Log +# MSBuild二进制和结构化日志 *.binlog # NVidia Nsight GPU debugger configuration file +# NVidia Nsight GPU调试器配置文件 *.nvuser # MFractors (Xamarin productivity tool) working folder +# MFractors(Xamarin生产力工具)工作文件夹 .mfractor/ # Local History for Visual Studio +# Visual Studio 的本地历史记录 .localhistory/ # BeatPulse healthcheck temp database +# BeatPulse healthcheck 临时数据库 healthchecksdb diff --git a/README.md b/README.md index 275c9ef12ca6be47ad8b6821031117e41912a4d1..dbf6dc63e20c4575b69e8c2eaa11fafab26e183e 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,80 @@ #### 浣跨敤璇存槑 -1. xxxx -2. xxxx -3. xxxx +1. 蹇熷叆闂 + + - 鎵撳紑vs锛屾柊寤轰竴涓猻tandard绫诲瀷鐨勭被搴撻」鐩紝淇敼椤圭洰鏂囦欢閲岀殑`netcore2.0`涓篳NET45`銆傚叾涓殑net45锛屽彲浠ユ敼涓簄et40浠ヤ笂鐨勪换浣曠増鏈紙net40銆乶et45銆乶et46銆乶et47锛夈傚悓鏃跺彲浠ユ寚瀹氬鐗堟湰銆傚叿浣撶殑璇︾粏鐨勬暀绋嬭 [VS閫氳繃娣诲姞涓嶅悓寮曠敤搴擄紝寤虹珛澶氭潯浠剁紪璇慮( https://www.yuque.com/vicwjb/zqpcd0/ufbwyl)銆 + - 鍙抽敭椤圭洰鏂囦欢锛岄夋嫨绠$悊nuget绋嬪簭鍖呫 + - 鍦╪uget绋嬪簭閲屾悳绱**ifoxcad**锛岀洿鎺ラ夋嫨鏈鏂扮殑鐗堟湰锛岀劧鍚庣偣鍑诲畨瑁咃紝nuget浼氳嚜鍔ㄥ畨瑁卛foxcad渚濊禆鐨勫簱銆 + - 娣诲姞寮曠敤 + + ```c# + using Autodesk.AutoCAD.ApplicationServices; + using Autodesk.AutoCAD.EditorInput; + using Autodesk.AutoCAD.Runtime; + using Autodesk.AutoCAD.Geometry; + using Autodesk.AutoCAD.DatabaseServices; + using IFoxCAD.Cad; + ``` + + - 娣诲姞浠g爜 + + ```c# + [CommandMethod("hello")] + public void Hello() + { + using (DBTrans tr = new DBTrans()) + { + Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); + tr.CurrentSpace.AddEntity(line1); + } + } + ``` + + + 杩欐浠g爜灏辨槸鍦╟ad鐨勫綋鍓嶇┖闂村唴娣诲姞浜嗕竴鏉$洿绾裤 + +- F6鐢熸垚锛岀劧鍚庢墦寮cad锛宯etload鍛戒护灏嗗垰鍒氱敓鎴愮殑dll鍔犺浇銆 + - 杩愯hello鍛戒护锛岀劧鍚庣缉鏀句竴涓嬭鍥撅紝鐜板湪涓鏉$洿绾垮拰涓涓渾宸茬粡鏄剧ず鍦ㄥ睆骞曚笂浜嗐 + +2. 浜嬪姟绠$悊鍣ㄧ敤娉 + +3. 閫夋嫨闆嗚繃婊ゅ櫒鐢ㄦ硶 + +4. 绗﹀彿琛ㄧ敤娉 + +5. WPF鏀寔 + +6. 澶╃鐨勮嚜鍔ㄥ姞杞戒笌鍒濆鍖 + + 涓轰簡灏嗙▼搴忛泦鐨勫垵濮嬪寲鍜岄氳繃鍐欐敞鍐岃〃鐨勬柟寮忓疄鐜拌嚜鍔ㄥ姞杞界粺涓璁剧疆锛屽噺灏戞瘡娆¢噸澶嶇殑宸ヤ綔閲忥紝鍐呰¥鎻愪緵浜哷AutoRegAssem`鎶借薄绫绘潵瀹屾垚姝ゅ姛鑳斤紝鍙鍦ㄩ渶瑕佸垵濮嬪寲鐨勭被缁ф壙`AutoRegAssem`绫伙紝鐒跺悗瀹炵幇`Initialize()` 鍜宍Terminate()`涓や釜鍑芥暟灏卞彲浠ヤ簡銆傜壒鍒己璋冪殑鏄紝涓涓▼搴忛泦閲屽彧鑳芥湁涓涓被缁ф壙锛屼笉绠℃槸涓嶆槸鍚屼竴涓懡鍚嶇┖闂淬 + + ```c# + public class Test : AutoRegAssem //缁ф壙 + { + public override void Initialize() //瀹炵幇鎺ュ彛鍑芥暟 + { + throw new NotImplementedException(); + } + public override void Terminate() //瀹炵幇鎺ュ彛鍑芥暟 + { + throw new NotImplementedException(); + } + } + ``` + +7. 澶╃鐨勬墦寮妯″紡鎻愭潈 + + 鐢变簬cad鐨勫璞℃槸鏈夋墦寮妯″紡锛屾槸鍚﹀彲鍐欑瓑绛夛紝涓轰簡瀹夊叏璧疯锛屽湪澶勭悊瀵硅薄鏃讹紝涓鑸槸鐢ㄨ妯″紡鎵撳紑锛岀劧鍚庨渶瑕佸啓鏁版嵁鐨勬椂鍊欏湪鎻愭潈涓哄啓妯″紡锛岀劧鍚庡湪闄嶇骇鍒拌妯″紡锛屼絾鏄繖涓繃绋嬩腑锛屽緢瀹规槗婕忔帀鏌愪簺姝ラ锛岀劧鍚巆ad宕╂簝銆備负浜嗗鐞嗚繖浜涙儏鍐碉紝鍐呰¥鎻愪緵浜嗘彁鏉冪被鏉ヤ繚璇佽鍐欐ā寮忕殑鏈夊簭杞崲銆 + + ```c# + using(line.ForWrite()) //寮鍚璞″啓妯″紡鎻愭潈浜嬪姟 + { + //澶勭悊浠g爜 + } //鍏抽棴浜嬪姟鑷姩澶勭悊璇诲啓妯″紡 + ``` + +8. 鏈畬寰呯画銆傘傘傘 #### 鍙備笌璐$尞 diff --git a/src/IFoxCAD.Cad/ExtensionMethod/CollectionEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/CollectionEx.cs index a2d32d9aa390ceb159c8a2bd0a7970c8697f2e8d..4e54ccb53889b50d243614b4a42484b87d060a53 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/CollectionEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/CollectionEx.cs @@ -56,7 +56,7 @@ public static Point2dCollection ToCollection(this IEnumerable pts) } /// - /// 涓夌淮鐐硅凯浠e櫒杞崲涓轰簩缁寸偣闆嗗悎 + /// 涓夌淮鐐硅凯浠e櫒杞崲涓轰笁缁寸偣闆嗗悎 /// /// 涓夌淮鐐硅凯浠e櫒 /// 涓夌淮鐐归泦鍚 diff --git a/src/IFoxCAD.Cad/ExtensionMethod/CoordinatesystemCode.cs b/src/IFoxCAD.Cad/ExtensionMethod/CoordinatesystemCode.cs new file mode 100644 index 0000000000000000000000000000000000000000..f839bd4f17aaa7ccbed3eaab3a97bce1e7f3eada --- /dev/null +++ b/src/IFoxCAD.Cad/ExtensionMethod/CoordinatesystemCode.cs @@ -0,0 +1,34 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace IFoxCAD.Cad +{ + /// + /// 鍧愭爣绯荤被鍨嬫灇涓 + /// + public enum CoordinateSystemCode + { + /// + /// 涓栫晫鍧愭爣绯 + /// + Wcs = 0, + + /// + /// 鐢ㄦ埛鍧愭爣绯 + /// + Ucs, + + /// + /// 妯″瀷绌洪棿鍧愭爣绯 + /// + MDcs, + + /// + /// 鍥剧焊绌洪棿鍧愭爣绯 + /// + PDcs + } + +} diff --git a/src/IFoxCAD.Cad/ExtensionMethod/DBObjectEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/DBObjectEx.cs index 6a2a4f3889f63ab698a4a821504bb1df816e620d..e612b27bfd18bbdb36e48b61e1bc5f6fa50e0aa4 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/DBObjectEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/DBObjectEx.cs @@ -39,10 +39,6 @@ public static void ChangeXData(this DBObject obj, string appName, DxfCode dxfCod } #endregion - - - - #region 璇诲啓妯″紡鍒囨崲 /// @@ -121,6 +117,5 @@ public void Dispose() #endregion IDisposable 鎴愬憳 } #endregion - } } diff --git a/src/IFoxCAD.Cad/ExtensionMethod/EditorEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/EditorEx.cs index 5f86426e19dd8316beaa46ff1c53a6f565e0f5c7..1a7f7a3a9fa801bbe887b9f550bae2b13d1c7c80 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/EditorEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/EditorEx.cs @@ -10,32 +10,6 @@ namespace IFoxCAD.Cad { - /// - /// 鍧愭爣绯荤被鍨嬫灇涓 - /// - public enum CoordinateSystemCode - { - /// - /// 涓栫晫鍧愭爣绯 - /// - Wcs = 0, - - /// - /// 鐢ㄦ埛鍧愭爣绯 - /// - Ucs, - - /// - /// 妯″瀷绌洪棿鍧愭爣绯 - /// - MDcs, - - /// - /// 鍥剧焊绌洪棿鍧愭爣绯 - /// - PDcs - } - /// /// 鍛戒护琛屾墿灞曠被 /// @@ -335,7 +309,7 @@ public static void DrawCircle(this Editor editor, Point2d pnt, short colorIndex, /// /// 鑾峰彇UCS鍒癢CS鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromUcsToWcs(this Editor editor) { @@ -345,7 +319,7 @@ public static Matrix3d GetMatrixFromUcsToWcs(this Editor editor) /// /// 鑾峰彇WCS鍒癠CS鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromWcsToUcs(this Editor editor) { @@ -355,7 +329,7 @@ public static Matrix3d GetMatrixFromWcsToUcs(this Editor editor) /// /// 鑾峰彇MDCS(妯″瀷绌洪棿)鍒癢CS鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromMDcsToWcs(this Editor editor) { @@ -369,7 +343,7 @@ public static Matrix3d GetMatrixFromMDcsToWcs(this Editor editor) /// /// 鑾峰彇WCS鍒癕DCS(妯″瀷绌洪棿)鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromWcsToMDcs(this Editor editor) { @@ -379,7 +353,7 @@ public static Matrix3d GetMatrixFromWcsToMDcs(this Editor editor) /// /// 鑾峰彇MDCS(妯″瀷绌洪棿)鍒癙DCS(鍥剧焊绌洪棿)鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromMDcsToPDcs(this Editor editor) { @@ -416,7 +390,7 @@ public static Matrix3d GetMatrixFromMDcsToPDcs(this Editor editor) /// /// 鑾峰彇PDCS(鍥剧焊绌洪棿)鍒癕DCS(妯″瀷绌洪棿)鐨勭煩闃 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍙樻崲鐭╅樀 public static Matrix3d GetMatrixFromPDcsToMDcs(this Editor editor) { @@ -426,7 +400,7 @@ public static Matrix3d GetMatrixFromPDcsToMDcs(this Editor editor) /// /// 鑾峰彇鍙樻崲鐭╅樀 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 婧愬潗鏍囩郴 /// 鐩爣鍧愭爣绯 /// 鍙樻崲鐭╅樀 @@ -513,14 +487,14 @@ public static Matrix3d GetMatrix(this Editor editor, CoordinateSystemCode from, #endif } -#endregion Matrix + #endregion Matrix -#region Zoom + #region Zoom /// /// 缂╂斁绐楀彛鑼冨洿 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 绐楀彛宸︿笅鐐 /// 绐楀彛鍙充笂鐐 public static void ZoomWindow(this Editor ed, Point3d minPoint, Point3d maxPoint) @@ -566,7 +540,7 @@ public static void ZoomWindow(this Editor ed, Point3d minPoint, Point3d maxPoint /// /// 缂╂斁绐楀彛鑼冨洿 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 绐楀彛鑼冨洿鐐 public static void ZoomWindow(this Editor ed, Extents3d ext) { @@ -574,12 +548,12 @@ public static void ZoomWindow(this Editor ed, Extents3d ext) } /// - /// Zooms the scaled. + /// 缂╂斁姣斾緥 /// - /// The ed. - /// The cen pt. - /// The width. - /// The height. + /// 鍛戒护琛屽璞 + /// 涓績鐐 + /// 绐楀彛瀹 + /// 绐楀彛楂 public static void Zoom(this Editor ed, Point3d CenPt, double width, double height) { using ViewTableRecord view = ed.GetCurrentView(); @@ -590,12 +564,12 @@ public static void Zoom(this Editor ed, Point3d CenPt, double width, double heig } /// - /// 瑙嗗浘鐨勭獥鍙g缉鏀 + ///缂╂斁绐楀彛鑼冨洿 /// - /// The ed. + /// 鍛戒护琛屽璞 /// 绗竴鐐 /// 瀵硅鐐 - /// + /// 鍋忕Щ璺濈 public static void ZoomWindow(this Editor ed, Point3d lpt, Point3d rpt, double offsetDist = 0.00) { Extents3d extents = new(); @@ -610,7 +584,7 @@ public static void ZoomWindow(this Editor ed, Point3d lpt, Point3d rpt, double o /// /// 鍔ㄦ佺缉鏀 /// - /// 缂栬緫鍣ㄥ璞 + /// 鍛戒护琛屽璞 /// 鍋忕Щ璺濈 public static void ZoomExtents(this Editor ed, double offsetDist = 0.00) { @@ -622,7 +596,7 @@ public static void ZoomExtents(this Editor ed, double offsetDist = 0.00) /// /// 鏍规嵁瀹炰綋瀵硅薄鐨勮寖鍥存樉绀鸿鍥 /// - /// + /// 鍛戒护琛屽璞 /// Entity瀵硅薄 /// 鍋忕Щ璺濈 public static void ZoomObject(this Editor ed, Entity ent, double offsetDist = 0.00) @@ -631,16 +605,16 @@ public static void ZoomObject(this Editor ed, Entity ent, double offsetDist = 0. ed.ZoomWindow(ext.MinPoint, ext.MinPoint, offsetDist); } -#endregion Zoom + #endregion Zoom -#region Get浜や簰绫 + #region Get浜や簰绫 /// /// 鑾峰彇Point /// - /// - /// - /// + /// 鍛戒护琛屽璞 + /// 鎻愮ず淇℃伅 + /// 鎻愮ず浣跨敤鐨勫熀鐐 /// public static PromptPointResult GetPoint(this Editor ed, string Message, Point3d BasePoint) { @@ -655,8 +629,8 @@ public static PromptPointResult GetPoint(this Editor ed, string Message, Point3d /// /// 鑾峰彇double鍊 /// - /// - /// 鏄剧ず淇℃伅 + /// 鍛戒护琛屽璞 + /// 鎻愮ず淇℃伅 /// double榛樿鍊 /// public static PromptDoubleResult GetDouble(this Editor ed, string Message, double DefaultValue = 1.0) @@ -671,8 +645,8 @@ public static PromptDoubleResult GetDouble(this Editor ed, string Message, doubl /// /// 鑾峰彇int鍊 /// - /// - /// 鏄剧ず淇℃伅 + /// 鍛戒护琛屽璞 + /// 鎻愮ず淇℃伅 /// double榛樿鍊 /// public static PromptIntegerResult GetInteger(this Editor ed, string Message, int DefaultValue = 1) @@ -687,9 +661,9 @@ public static PromptIntegerResult GetInteger(this Editor ed, string Message, int /// /// 鑾峰彇string鍊 /// - /// - /// - /// + /// 鍛戒护琛屽璞 + /// 鎻愮ず淇℃伅 + /// string榛樿鍊 /// public static PromptResult GetString(this Editor ed, string Message, string DefaultValue = "") { @@ -700,9 +674,9 @@ public static PromptResult GetString(this Editor ed, string Message, string Defa return ed.GetString(strOp); } -#endregion Get浜や簰绫 + #endregion Get浜や簰绫 -#region 鎵цlisp + #region 鎵цlisp [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, @@ -736,6 +710,6 @@ public static ResultBuffer RunLisp(this Editor ed, string arg) return null; } -#endregion 鎵цlisp + #endregion 鎵цlisp } } \ No newline at end of file diff --git a/src/IFoxCAD.Cad/ExtensionMethod/EntityEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/EntityEx.cs index 7d0c8d767aaaeb9c952ca1c94c81ab35e209a89f..38efca400d715572ef61b7dc806b06a82d54a2ad 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/EntityEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/EntityEx.cs @@ -181,7 +181,8 @@ public static Extents3d GetExtents(this IEnumerable ents) } #endregion - #region 澶氳鏂囧瓧 + #region 鍗曡鏂囧瓧 + /// /// 鏇存鍗曡鏂囧瓧鐨勯暅鍍忓睘鎬 /// @@ -194,6 +195,9 @@ public static void ValidateMirror(this DBText txt) txt.IsMirroredInY = false; } } + #endregion + + #region 澶氳鏂囧瓧 /// /// 鐐告暎澶氳鏂囧瓧 diff --git a/src/IFoxCAD.Cad/ExtensionMethod/SymbolTableRecordEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/SymbolTableRecordEx.cs index e3d9bf1bd98ab308f80f8c2746dd300a66d9fe9a..b3b98907174e38f06a83e4f0740ae173cd05d29f 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/SymbolTableRecordEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/SymbolTableRecordEx.cs @@ -57,6 +57,16 @@ public static List AddEntity(this BlockTableRecord btr, IEnumerable .ToList(); } } + /// + /// 娣诲姞澶氫釜瀹炰綋 + /// + /// + /// + /// + public static List AddEntity(this BlockTableRecord btr, params Entity[] ents) + { + return btr.AddEntity(ents, null); + } #endregion #region 娣诲姞鍥惧厓 @@ -69,7 +79,7 @@ public static List AddEntity(this BlockTableRecord btr, IEnumerable /// 鍥惧厓灞炴ц缃鎵 /// 浜嬪姟绠$悊鍣 /// 鍥惧厓id - private static ObjectId DrawEnt(this BlockTableRecord btr, T ent, Action action, Transaction trans) where T : Entity + private static ObjectId AddEnt(this BlockTableRecord btr, T ent, Action action, Transaction trans) where T : Entity { trans ??= DBTrans.Top.Trans; action?.Invoke(ent); @@ -85,10 +95,10 @@ private static ObjectId DrawEnt(this BlockTableRecord btr, T ent, Action a /// 缁樺浘绌洪棿 /// 鐩寸嚎灞炴ц缃鎵 /// 鐩寸嚎鐨刬d - public static ObjectId DrawLine(this BlockTableRecord btr, Point3d start, Point3d end, Action action = default, Transaction trans = default) + public static ObjectId AddLine(this BlockTableRecord btr, Point3d start, Point3d end, Action action = default, Transaction trans = default) { var line = new Line(start, end); - return btr.DrawEnt(line, action, trans); + return btr.AddEnt(line, action, trans); } /// /// 鍦ㄦ寚瀹氱粯鍥剧┖闂碭-Y骞抽潰娣诲姞鍦 @@ -99,10 +109,10 @@ public static ObjectId DrawLine(this BlockTableRecord btr, Point3d start, Point3 /// 鍦嗗睘鎬ц缃鎵 /// 浜嬪姟绠$悊鍣 /// 鍦嗙殑id - public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d center, double radius, Action action = default, Transaction trans = default) + public static ObjectId AddCircle(this BlockTableRecord btr, Point3d center, double radius, Action action = default, Transaction trans = default) { var circle = new Circle(center, Vector3d.ZAxis, radius); - return btr.DrawEnt(circle, action, trans); + return btr.AddEnt(circle, action, trans); } /// @@ -115,7 +125,7 @@ public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d center, dou /// 鍦嗗睘鎬ц缃鎵 /// 浜嬪姟绠$悊鍣 /// 涓夌偣鏈夊鎺ュ渾鍒欒繑鍥炲渾鐨刬d锛屽惁鍒欒繑鍥濷bjectId.Null - public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d p0, Point3d p1, Point3d p2, Action action = default, Transaction trans = default) + public static ObjectId AddCircle(this BlockTableRecord btr, Point3d p0, Point3d p1, Point3d p2, Action action = default, Transaction trans = default) { var dx1 = p1.X - p0.X; var dy1 = p1.Y - p0.Y; @@ -123,7 +133,7 @@ public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d p0, Point3d var dy2 = p2.Y - p0.Y; var d = dx1 * dy2 - dx2 * dy1; - + if (d != 0.0) { var d2 = d * 2; @@ -131,7 +141,7 @@ public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d p0, Point3d var c2 = (p0.X + p2.X) * dx2 + (p0.Y + p2.Y) * dy2; var ce = new Point3d((c1 * dy2 - c2 * dy1) / d2, (c2 * dx1 - c1 * dx2) / d2, 0); var circle = new Circle(ce, Vector3d.ZAxis, p0.DistanceTo(ce)); - return btr.DrawEnt(circle, action, trans); + return btr.AddEnt(circle, action, trans); } return ObjectId.Null; } @@ -146,7 +156,7 @@ public static ObjectId DrawCircle(this BlockTableRecord btr, Point3d p0, Point3d /// 杞诲娈电嚎灞炴ц缃鎵 /// 浜嬪姟绠$悊鍣 /// 杞诲娈电嚎 - public static ObjectId DrawPline(this BlockTableRecord btr, List pts, List bulges = default, List startWidths = default, List endWidths = default, Action action = default, Transaction trans = default) + public static ObjectId AddPline(this BlockTableRecord btr, List pts, List bulges = default, List startWidths = default, List endWidths = default, Action action = default, Transaction trans = default) { bulges ??= new List(new double[pts.Count]); startWidths ??= new List(new double[pts.Count]); @@ -156,7 +166,7 @@ public static ObjectId DrawPline(this BlockTableRecord btr, List pts, L { pl.AddVertexAt(i, pts[i].Point2d(), bulges[i], startWidths[i], endWidths[i]); } - return btr.DrawEnt(pl, action, trans); + return btr.AddEnt(pl, action, trans); } /// @@ -169,14 +179,14 @@ public static ObjectId DrawPline(this BlockTableRecord btr, List pts, L /// 鍦嗗姬灞炴ц缃鎵 /// 浜嬪姟绠$悊鍣 /// 鍦嗗姬id - public static ObjectId DrawArc(this BlockTableRecord btr, Point3d startPoint, Point3d pointOnArc, Point3d endPoint, Action action = default, Transaction trans = default) + public static ObjectId AddArc(this BlockTableRecord btr, Point3d startPoint, Point3d pointOnArc, Point3d endPoint, Action action = default, Transaction trans = default) { var arc = new CircularArc3d(startPoint, pointOnArc, endPoint); #if ac2009 - return btr.DrawEnt(arc.ToArc(), action, trans); + return btr.AddEnt(arc.ToArc(), action, trans); #elif ac2013 - return btr.DrawEnt(Curve.CreateFromGeCurve(arc) as Arc, action, trans); + return btr.AddEnt(Curve.CreateFromGeCurve(arc) as Arc, action, trans); #endif } #endregion @@ -247,7 +257,7 @@ public static DrawOrderTable GetDrawOrderTable(this BlockTableRecord btr, Transa /// /// 鎻掑叆鐐 /// 鍧楀悕 - /// 鍧楁彃鍏ユ瘮渚嬶紝榛樿涓0 + /// 鍧楁彃鍏ユ瘮渚嬶紝榛樿涓1 /// 鍧楁彃鍏ユ棆杞(寮у害)锛岄粯璁や负0 /// 灞炴у瓧鍏竰Tag,Value}锛岄粯璁や负null /// 鍧楀弬鐓у璞d @@ -270,7 +280,7 @@ public static ObjectId InsertBlock(this BlockTableRecord blockTableRecord, Point /// /// 鎻掑叆鐐 /// 鍧楀畾涔塱d - /// 鍧楁彃鍏ユ瘮渚嬶紝榛樿涓0 + /// 鍧楁彃鍏ユ瘮渚嬶紝榛樿涓1 /// 鍧楁彃鍏ユ棆杞(寮у害)锛岄粯璁や负0 /// 灞炴у瓧鍏竰Tag,Value}锛岄粯璁や负null /// 鍧楀弬鐓у璞d diff --git a/src/IFoxCAD.Cad/ResultData/LispDottedPair.cs b/src/IFoxCAD.Cad/ResultData/LispDottedPair.cs index 94bebfa5b4324d9d03136e97052ee9bd948f7a13..9acad02506d333d587de5001043d5539416def51 100644 --- a/src/IFoxCAD.Cad/ResultData/LispDottedPair.cs +++ b/src/IFoxCAD.Cad/ResultData/LispDottedPair.cs @@ -10,6 +10,7 @@ namespace IFoxCAD.Cad /// public class LispDottedPair : LispList { + #region 鏋勯犲嚱鏁 /// /// 榛樿鏃犲弬鏋勯犲嚱鏁 /// @@ -34,6 +35,8 @@ public LispDottedPair(TypedValue left, TypedValue right) Add(left); Add(right); } + #endregion + /// /// 鐐瑰琛ㄧ殑鍊 /// @@ -63,7 +66,7 @@ public override List Value /// /// TypedValueList 瀹炰緥 public static implicit operator ResultBuffer(LispDottedPair values) => new(values.Value.ToArray()); - + #endregion } } \ No newline at end of file diff --git a/src/IFoxCAD.Cad/ResultData/LispList.cs b/src/IFoxCAD.Cad/ResultData/LispList.cs index fba1f47d1fa8fd7b75415cfda094c5ea5b4824ad..8f87c2f5f71c57e318917c573bb0a91930d09776 100644 --- a/src/IFoxCAD.Cad/ResultData/LispList.cs +++ b/src/IFoxCAD.Cad/ResultData/LispList.cs @@ -14,6 +14,7 @@ namespace IFoxCAD.Cad /// public class LispList : TypedValueList { + #region 鏋勯犲嚱鏁 /// /// 榛樿鏋勯犲嚱鏁 /// @@ -24,7 +25,7 @@ public LispList() { } /// /// TypedValue 杩唬鍣 public LispList(IEnumerable values) : base(values) { } - + #endregion /// /// lisp 鍒楄〃鐨勫 /// diff --git a/tests/DBTrans.test/Test.cs b/tests/DBTrans.test/Test.cs index d7e0d729e8570d208491da80681bffeb4866c651..ae6e9b8a3239383ab36ac87c7fdd488d111c55be 100644 --- a/tests/DBTrans.test/Test.cs +++ b/tests/DBTrans.test/Test.cs @@ -69,7 +69,7 @@ public void Addent() public void drawarc() { using var tr = new DBTrans(); - tr.CurrentSpace.DrawArc(new Point3d(0, 0, 0), new Point3d(1, 1, 0), new Point3d(2, 0, 0)); + tr.CurrentSpace.AddArc(new Point3d(0, 0, 0), new Point3d(1, 1, 0), new Point3d(2, 0, 0)); } [CommandMethod("layertest")] @@ -97,7 +97,7 @@ public void Layertest() public void Layertest1() { using var tr = new DBTrans(); - tr.LayerTable.Add("test1", Color.FromColorIndex(ColorMethod.ByColor,1)); + tr.LayerTable.Add("test1", Color.FromColorIndex(ColorMethod.ByColor, 1)); } //娣诲姞鍥惧眰 @@ -121,7 +121,7 @@ public void LayerDel() tr.LayerTable.Remove("2"); //娴嬭瘯鏄惁鑳藉己鍒跺垹闄 } - + //娣诲姞鐩寸嚎 [CommandMethod("linedemo1")] public void AddLine1() @@ -141,8 +141,12 @@ public void AddLine1() // { // line. // }); - Line line = new(new Point3d(0,0,0),new Point3d(1,1,0)); - tr.CurrentSpace.AddEntity(line); + Line line1 = new(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); + Line line2 = new(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); + Line line3 = new(new Point3d(1, 1, 0), new Point3d(3, 3, 0)); + Circle circle = new Circle(new Point3d(0, 0, 0), Vector3d.ZAxis, 10); + tr.CurrentSpace.AddEntity(line1); + tr.CurrentSpace.AddEntity(line2, line3, circle); } //澧炲姞澶氭绾1 @@ -151,11 +155,11 @@ public void AddPolyline1() { using var tr = new DBTrans(); Polyline pl = new Polyline(); - pl.AddVertexAt(0, new Point2d(0,0), 0, 0, 0); - pl.AddVertexAt(1, new Point2d(10,10), 0, 0, 0); - pl.AddVertexAt(2, new Point2d(20,20), 0, 0, 0); - pl.AddVertexAt(3, new Point2d(30,30), 0, 0, 0); - pl.AddVertexAt(4, new Point2d(40,40), 0, 0, 0); + pl.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0); + pl.AddVertexAt(1, new Point2d(10, 10), 0, 0, 0); + pl.AddVertexAt(2, new Point2d(20, 20), 0, 0, 0); + pl.AddVertexAt(3, new Point2d(30, 30), 0, 0, 0); + pl.AddVertexAt(4, new Point2d(40, 40), 0, 0, 0); pl.Closed = true; pl.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); tr.CurrentSpace.AddEntity(pl); @@ -167,10 +171,10 @@ public void BlockDef() { using var tr = new DBTrans(); //var line = new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); - tr.BlockTable.Add("test", + tr.BlockTable.Add("test", () => //鍥惧厓 { - return new List { new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0))}; + return new List { new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0)) }; }, () => //灞炴у畾涔 { @@ -179,6 +183,8 @@ public void BlockDef() return new List { id1, id2 }; } ); + ObjectId objectId = tr.BlockTable.Add("a");//鏂板缓鍧 + objectId.GetObject().AddEntity();//娴嬭瘯娣诲姞绌哄疄浣 } //淇敼鍧楀畾涔 [CommandMethod("blockdefchange")] @@ -193,7 +199,7 @@ public void BlockDefChange() btr.GetEntities() .ToList() .ForEach(e => e.Flush()); //鍒锋柊鍧楁樉绀 - + }); tr.Editor.Regen(); } @@ -227,14 +233,14 @@ public void AddXdata() { using var tr = new DBTrans(); var appname = "myapp"; - + tr.RegAppTable.Add(appname); // add鍑芥暟浼氶粯璁ょ殑鍦ㄥ瓨鍦ㄨ繖涓悕瀛楃殑鏃跺欒繑鍥炶繖涓悕瀛楃殑regapp鐨刬d锛屼笉瀛樺湪灏辨柊寤 - + var line = new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); - line.XData = new XDataList() - { + line.XData = new XDataList() + { { DxfCode.ExtendedDataRegAppName, appname }, //鍙互鐢╠xfcode鍜宨nt琛ㄧず缁勭爜 { DxfCode.ExtendedDataAsciiString, "hahhahah" }, {1070, 12 } @@ -279,7 +285,7 @@ public void Changexdata() { DxfCode.ExtendedDataLayerName, "0"} }; } - + //tr.AddEntity(data); ed.WriteMessage(data.XData.ToString()); @@ -345,7 +351,7 @@ public void cbll() //tr.BlockTable.GetBlockFrom(filename, true); string blkdefname = SymbolUtilityServices.RepairSymbolName(SymbolUtilityServices.GetSymbolNameFromPathName(filename, "dwg"), false); tr.Database.Insert(blkdefname, tr1.Database, false); //鎻掑叆浜嗗潡瀹氫箟锛屾湭鎻掑叆鍧楀弬鐓 - + }