資源簡介
添加兩個dll引用,CAD安裝文件夾下的acdb,acmgd;設置啟動程序為acad.exe

代碼片段和文件信息
/*?Author:hyb
?*?Tele:18323432139
?*?Time:2014-8-11
?*?Discribtion:凸邊界搜索函數
?*?*/
using?Autodesk.AutoCAD.DatabaseServices;
using?Autodesk.AutoCAD.Geometry;
using?Autodesk.AutoCAD.Runtime;
using?Autodesk.AutoCAD.EditorInput;
using?System.Collections.Generic;
using?System.Linq;
namespace?Search
{
????public?class?Class1
????{
????????[CommandMethod(“hyb_T“)]
????????public?void?search()
????????{
????????????DBPoint?Ap;
????????????DBPoint?temp;
????????????//獲取圖紙點集,并進行排序
????????????DBobjectCollection?dbc=?Collection();
????????????List?pts?=?new?List();
????????????foreach?(DBobject?dbo?in?dbc)
????????????{
????????????????if?(dbo.GetType().Name.ToString()?==?“DBPoint“)
????????????????{
????????????????????DBPoint?pt?=?(DBPoint)dbo;
????????????????????pts.Add(pt);
????????????????}
????????????}
????????????var?m=?pts.OrderBy(i?=>?i.Position.X);
????????????pts?=?m.ToList();
????????????DBPoint[]?DBps?=?pts.ToArray();
????????????//計算臨近邊界點集,并繪制邊界
????????????Ap?=?pts[0];
????????????temp?=?pts[1];
????????????List?ls=new?List();
????????????DBPoint?End=new?DBPoint();
????????????do{
????????????????End?=?select(Ap?temp?DBps);
????????????????ls.Add(new?Line(Ap.Position?End.Position));
????????????????temp?=?Ap;
????????????????Ap?=?End;
????????????}?while?(End?!=?pts[0]);
????????????foreach?(Line?l?in?ls)
????????????{
????????????????ToModelSpace(l);
????????????}
????????}
????????///?
????????///?選擇集合
????????///?
????????///?
????????public?static?DBobjectCollection?Collection()
????????{
????????????Database?db?=?Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
????????????Editor?ed?=?Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
????????????Entity?entity?=?null;
????????????DBobjectCollection?EntityCollection?=?new?DBobjectCollection();
????????????PromptSelectionResult?ents?=?ed.GetSelection();
????????????if?(ents.Status?==?PromptStatus.OK)
????????????{
????????????????using?(Transaction?transaction?=?db.TransactionManager.StartTransaction())
????????????????{
????????????????????SelectionSet?SS?=?ents.Value;
????????????????????foreach?(objectId?id?in?SS.GetobjectIds())
????????????????????{
????????????????????????entity?=?(Entity)transaction.Getobject(id?OpenMode.ForWrite?true);
????????????????????????if?(entity?!=?null)
????????????????????????????EntityCollection.Add(entity);
????????????????????}
????????????????????transaction.Commit();
????????????????}
????????????}
????????????return?EntityCollection;
????????}
????????///?
????????///?計算臨近邊界點
????????///?
????????///?起點
????????///?終點
????????///?點集
????????///?
????????private?DBPoint?select(DBPoint?spDBPoin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7680??2014-08-12?10:08??Search\Search\bin\Debug\Search.dll
?????文件??????15872??2014-08-12?10:08??Search\Search\bin\Debug\Search.pdb
?????文件???????4718??2014-08-11?16:43??Search\Search\Class1.cs
?????文件???????5819??2014-08-12?10:08??Search\Search\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????83467??2014-08-11?13:34??Search\Search\obj\Debug\ResolveAssemblyReference.cache
?????文件???????7680??2014-08-12?10:08??Search\Search\obj\Debug\Search.dll
?????文件??????15872??2014-08-12?10:08??Search\Search\obj\Debug\Search.pdb
?????文件????????320??2014-08-11?14:42??Search\Search\obj\Debug\Search_T.csproj.FileListAbsolute.txt
?????文件???????1362??2014-08-11?12:59??Search\Search\Properties\AssemblyInfo.cs
?????文件???????2690??2014-08-11?13:34??Search\Search\Search_T.csproj
?????文件????????386??2014-08-11?13:34??Search\Search\Search_T.csproj.user
?????文件????????912??2014-08-11?13:34??Search\Search.sln
????..A..H.?????17920??2014-08-12?17:32??Search\Search.suo
?????文件?????????10??2014-08-12?10:23??Search\說明.txt
?????目錄??????????0??2014-08-11?12:59??Search\Search\obj\Debug\TempPE
?????目錄??????????0??2014-08-11?13:34??Search\Search\bin\Debug
?????目錄??????????0??2014-08-12?10:08??Search\Search\obj\Debug
?????目錄??????????0??2014-08-11?12:59??Search\Search\bin
?????目錄??????????0??2014-08-11?12:59??Search\Search\obj
?????目錄??????????0??2014-08-11?12:59??Search\Search\Properties
?????目錄??????????0??2014-08-11?13:00??Search\Search
?????目錄??????????0??2014-08-12?10:23??Search
-----------?---------??----------?-----??----
???????????????164708????????????????????22
評論
共有 條評論