中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

做網(wǎng)站實現(xiàn)登陸功能十八大禁用黃app入口

做網(wǎng)站實現(xiàn)登陸功能,十八大禁用黃app入口,山西建站推廣,wordpress css圖標(biāo)運行環(huán)境Visual Studio 2022 c# cad2016 cass10 通過面積計算得到擴展數(shù)據(jù),宗地面積 ,房屋占地面積,房屋使用面積 一、主要步驟 獲取當(dāng)前AutoCAD應(yīng)用中的活動文檔、數(shù)據(jù)庫和編輯器對象。創(chuàng)建一個選擇過濾器,限制用戶只能選擇&q…

運行環(huán)境Visual?Studio 2022 c# cad2016 cass10

通過面積計算得到擴展數(shù)據(jù),宗地面積?,房屋占地面積,房屋使用面積

一、主要步驟

  1. 獲取當(dāng)前AutoCAD應(yīng)用中的活動文檔、數(shù)據(jù)庫和編輯器對象。
  2. 創(chuàng)建一個選擇過濾器,限制用戶只能選擇"宗地"圖層上的LWPOLYLINE對象作為外部邊界。
  3. 提示用戶根據(jù)上述規(guī)則進(jìn)行實體選擇,并獲取選擇結(jié)果。
  4. 遍歷所有被選中的外部多段線,確保所選多段線是閉合的且至少有一個頂點。
  5. 創(chuàng)建并填充一個表示外部多段線邊界坐標(biāo)的點集合。
  6. 使用多邊形窗口選擇方式讓用戶選擇位于外部多段線內(nèi)的實體。
  7. 遍歷用戶在內(nèi)部區(qū)域所選的所有閉合多段線,計算房屋面積和附屬面積。
  8. 計算宗地面積和輸出結(jié)果。

二、完整代碼

internal class zdfwmj
{public static List<string> filelist1 = new List<string>();public static List<string> filelist2 = new List<string>();public void fwzymj(){// 獲取當(dāng)前AutoCAD應(yīng)用中的活動文檔、數(shù)據(jù)庫和編輯器對象Document doc = Application.DocumentManager.MdiActiveDocument;Database db = doc.Database;Editor ed = doc.Editor;string SelectedLayerName = CreatePalette.SelectedLayerName;NumberContainer numberContainer = new NumberContainer();//ed.WriteMessage("選擇的圖層:" + SelectedLayerName + "\n");// 創(chuàng)建一個選擇過濾器,限制用戶只能選擇"宗地"圖層上的LWPOLYLINE對象作為外部邊界SelectionFilter outerFilter = new SelectionFilter(new TypedValue[] {new TypedValue((int)DxfCode.Start, "LWPOLYLINE"),new TypedValue((int)DxfCode.LayerName, SelectedLayerName)});// 提示用戶根據(jù)上述規(guī)則進(jìn)行實體選擇,并獲取選擇結(jié)果PromptSelectionResult outerSelRes = ed.GetSelection(outerFilter);// 檢查用戶是否成功選擇了實體if (outerSelRes.Status == PromptStatus.OK){using (Transaction tr = db.TransactionManager.StartTransaction())// 開始事務(wù)處理以確保數(shù)據(jù)一致性{foreach (ObjectId outerId in outerSelRes.Value.GetObjectIds())// 遍歷所有被選中的外部多段線{using (Polyline outerPolyline = (Polyline)tr.GetObject(outerId, OpenMode.ForRead))// 讀取所選多段線{// 確保所選多段線是閉合的且至少有一個頂點double totalArea = 0; // 總面積double totalAreaZdmj = 0; // 總面積double totalAreaSYmj = 0; // 總面積if (outerPolyline.Closed && outerPolyline.NumberOfVertices > 0){// 創(chuàng)建并填充一個表示外部多段線邊界坐標(biāo)的點集合Point3dCollection outerPoints = new Point3dCollection();for (int i = 0; i < outerPolyline.NumberOfVertices; i++){Point3d point = outerPolyline.GetPoint3dAt(i);// 獲取多邊形的中心點Point3d center = GetCenterOfPolyline(outerPolyline);// 定義你的擴展因子,比如 1.5 表示擴大1.5倍double scaleFactor = 1.2;// 將頂點向中心點平移,然后按比例縮放Point3d scaledPoint = new Point3d((point.X - center.X) * scaleFactor + center.X,(point.Y - center.Y) * scaleFactor + center.Y,(point.Z - center.Z) * scaleFactor + center.Z);// 創(chuàng)建并設(shè)置文本對象DBText text = new DBText();text.TextString = i.ToString();//text.Height = 1; // 文字高度設(shè)為1個單位text.Position = scaledPoint;將文本添加到模型空間//using (Transaction transaction = db.TransactionManager.StartTransaction())//{//    BlockTable bt = transaction.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;//    BlockTableRecord ms = transaction.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;//    ms.AppendEntity(text);//    transaction.AddNewlyCreatedDBObject(text, true);//    transaction.Commit();//}outerPoints.Add(scaledPoint);}// 創(chuàng)建一個窗口選擇過濾器,用于選擇位于外部多段線內(nèi)的所有實體SelectionFilter innerFilter = new SelectionFilter(new TypedValue[] {new TypedValue((int)DxfCode.Start, "LWPOLYLINE"),new TypedValue((int)DxfCode.LayerName, "JMD")});// 使用多邊形窗口選擇方式讓用戶選擇位于外部多段線內(nèi)的實體PromptSelectionResult innerSelRes = ed.SelectWindowPolygon(outerPoints, innerFilter);// 檢查用戶是否成功在內(nèi)部區(qū)域進(jìn)行了實體選擇if (innerSelRes.Status == PromptStatus.OK){SelectionSet innerSelectionSet = innerSelRes.Value;// 遍歷用戶在內(nèi)部區(qū)域所選的所有閉合多段線foreach (ObjectId id2 in innerSelectionSet.GetObjectIds()){using (Polyline polyline2 = (Polyline)tr.GetObject(id2, OpenMode.ForRead)){if (polyline2.Closed && polyline2.NumberOfVertices > 0){Entity ent2 = (Entity)tr.GetObject(id2, OpenMode.ForWrite);//ent2.Color = Color.FromColorIndex(ColorMethod.ByAci, 3); // 示例:將顏色設(shè)為黃色//ed.UpdateScreen(); // 確保顏色更改即時生效filelist1.Clear();filelist2.Clear();int filelist1ii = 0;if (ent2 != null && ent2.XData != null){List<int> numbers01 = new List<int> { 141161, 141121, 141151 };//房屋編碼List<int> numbers02 = new List<int> { 141800, 140001, 143130, 143111, 143112 };//房屋附屬編碼ResultBuffer rb = ent2.GetXDataForApplication("SOUTH");string xdata = rb.ToString();foreach (TypedValue tv in rb){filelist1.Add(tv.TypeCode.ToString());//碼filelist2.Add(tv.Value.ToString());//值}filelist1ii = filelist1.Count();//房屋面積if (filelist1ii == 3){if (numbers01.Contains(Convert.ToInt32(filelist2[1]))){string fwjg = numberContainer.GetDescription(Convert.ToInt32(filelist2[1]));int fileValue;if (int.TryParse(filelist2[2], out fileValue)){double calculatedUsageArea = polyline2.Area * fileValue;//ed.WriteMessage($"\n房屋面積信息:{fwjg}{fileValue} 占地面積:{polyline2.Area:N2} 使用面積:{calculatedUsageArea:N2}\n");totalAreaZdmj += polyline2.Area;totalAreaSYmj += calculatedUsageArea;using (Transaction transaction = db.TransactionManager.StartTransaction()){RegAppTable table02 = (RegAppTable)transaction.GetObject(doc.Database.RegAppTableId, OpenMode.ForWrite, false);ResultBuffer rb02 = new ResultBuffer();string appName02 = "擴展數(shù)據(jù)";if (!table02.Has(appName02)){RegAppTableRecord regAppRec = new RegAppTableRecord();regAppRec.Name = appName02;table02.Add(regAppRec);transaction.AddNewlyCreatedDBObject(regAppRec, true);}rb02.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, appName02));rb02.Add(new TypedValue((int)DxfCode.ExtendedDataReal, polyline2.Area));rb02.Add(new TypedValue((int)DxfCode.ExtendedDataReal, calculatedUsageArea));ent2.XData = rb02;transaction.Commit();}}else{//ed.WriteMessage("\n無法將文件列表中的值轉(zhuǎn)換為整數(shù)以計算使用面積!");}}}if (filelist1ii == 2){ed.WriteMessage("\n附屬編碼:" + filelist2[1]);if (numbers02.Contains(Convert.ToInt32(filelist2[1]))){string fwjg = numberContainer.GetDescription(Convert.ToInt32(filelist2[1]));//double fsmj = FwmjArea(polyline2, db, ed, tr);TypedValue[] tvs = new TypedValue[]{new TypedValue((int)DxfCode.Operator, "<and"),new TypedValue((int)DxfCode.Start, "TEXT"),new TypedValue((int)DxfCode.LayerName, "房屋附屬1"),new TypedValue((int)DxfCode.Operator, "and>")};SelectionFilter sf = new SelectionFilter(tvs);PromptSelectionResult psr = ed.SelectAll(sf);SelectionSet ss = psr.Value;foreach (SelectedObject so in ss){DBText text = tr.GetObject(so.ObjectId, OpenMode.ForRead) as DBText;if (IsPointInside(polyline2, text.Position)){string input = text.TextString;//文字分解string[] parts = input.Split(' ');foreach (string part in parts){// 按中文逗號分割鍵值對string[] keyValue = part.Split(','); // 注意:這里的逗號是中文逗號,不是英文逗號if (keyValue.Length == 2){string key = keyValue[0];string value = keyValue[1];//ed.WriteMessage("鍵: " + key + ", 值: " + value+ "\n");bool result = key.Contains("Q");if (result){totalArea += polyline2.Area;//ed.WriteMessage($"全:{key}{value} 附屬面積:{polyline2.Area:N2}\n");}result = key.Contains("B");if (result){totalArea += polyline2.Area / 2;//ed.WriteMessage($"半:{key}{value} 附屬面積:{polyline2.Area:N2}\n");}}else{//ed.WriteMessage("未能分割出鍵值對:" + part);}}using (Transaction transaction = db.TransactionManager.StartTransaction()){RegAppTable table02 = (RegAppTable)transaction.GetObject(doc.Database.RegAppTableId, OpenMode.ForWrite, false);ResultBuffer rb02 = new ResultBuffer();string appName02 = "擴展數(shù)據(jù)";if (!table02.Has(appName02)){RegAppTableRecord regAppRec = new RegAppTableRecord();regAppRec.Name = appName02;table02.Add(regAppRec);transaction.AddNewlyCreatedDBObject(regAppRec, true);}rb02.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, appName02));rb02.Add(new TypedValue((int)DxfCode.ExtendedDataAsciiString, input));rb02.Add(new TypedValue((int)DxfCode.ExtendedDataReal, totalArea));ent2.XData = rb02;transaction.Commit();}//ed.WriteMessage($"房屋附屬:{input} 附屬面積:{totalArea:N2}\n");}}   }}}}}}}Entity ent01 = tr.GetObject(outerId, OpenMode.ForWrite) as Entity;RegAppTable table = (RegAppTable)tr.GetObject(doc.Database.RegAppTableId, OpenMode.ForWrite, false);ResultBuffer rb01 = new ResultBuffer();string appName = "擴展數(shù)據(jù)";if (!table.Has(appName)){RegAppTableRecord regAppRec = new RegAppTableRecord();regAppRec.Name = appName;table.Add(regAppRec);tr.AddNewlyCreatedDBObject(regAppRec, true);}rb01.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, appName));rb01.Add(new TypedValue((int)DxfCode.ExtendedDataReal, outerPolyline.Area));rb01.Add(new TypedValue((int)DxfCode.ExtendedDataReal, totalAreaZdmj));rb01.Add(new TypedValue((int)DxfCode.ExtendedDataReal, (totalAreaSYmj + totalArea)));ent01.XData = rb01;}//ed.WriteMessage($"\n宗地面積:{outerPolyline.Area:N2} \n\n房屋占地面積:{totalAreaZdmj:N2}\n房屋使用面積:{(totalAreaSYmj + totalArea):N2}\n");}}tr.Commit();}}}/// <summary>FwmjAreapublic double FwmjArea(Polyline polyline, Database db, Editor ed, Transaction tr){Point3dCollection outerPoints = new Point3dCollection(); // 創(chuàng)建并填充一個表示外部多段線邊界坐標(biāo)的點集合double areaFWFS = 0;//房屋附屬面積for (int i = 0; i < polyline.NumberOfVertices; i++){Point3d point = polyline.GetPoint3dAt(i);outerPoints.Add(point);}// 創(chuàng)建一個窗口選擇過濾器,用于選擇位于外部多段線內(nèi)的所有實體SelectionFilter innerFilter = new SelectionFilter(new TypedValue[] {new TypedValue((int)DxfCode.Operator, "<and"),new TypedValue((int)DxfCode.Start, "TEXT"),new TypedValue((int)DxfCode.LayerName, "房屋附屬1"),new TypedValue((int)DxfCode.Operator, "and>")});// 使用多邊形窗口選擇方式讓用戶選擇位于外部多段線內(nèi)的實體PromptSelectionResult innerSelRes = ed.SelectAll(innerFilter);if (innerSelRes.Status == PromptStatus.OK){SelectionSet innerSelectionSet = innerSelRes.Value;foreach (SelectedObject so in innerSelectionSet){DBText text = tr.GetObject(so.ObjectId, OpenMode.ForRead) as DBText;if (IsPointInside(polyline, text.Position)){string input = text.TextString;//ed.WriteMessage("\n房屋附屬文字2:", input.ToString());//ed.WriteMessage("\n房屋附屬文字2:", polyline.Area);}}}return areaFWFS;}/// </summary>/// <param name="polyline"></param>/// <param name="point"></param>/// <returns></returns>// 定義一個方法,輸入?yún)?shù)為一個多段線對象和一個三維點,返回值為布爾類型,表示該點是否在多段線內(nèi)部public bool IsPointInside(Polyline polyline, Point3d point){// 初始化交叉次數(shù)變量為0,用于記錄點與多段線各線段相交的次數(shù)int crossings = 0;// 遍歷多段線的所有頂點,從第一個頂點開始到最后一個頂點for (int i = 0; i < polyline.NumberOfVertices; i++){// 獲取當(dāng)前線段的起點坐標(biāo)Point3d start = polyline.GetPoint3dAt(i);// 計算下一個頂點的索引,并使用取模運算確保最后一個頂點后回到第一個頂點形成閉合循環(huán)int nextIndex = (i + 1) % polyline.NumberOfVertices;Point3d end = polyline.GetPoint3dAt(nextIndex);// 如果線段兩端點都在檢測點Y軸上方或下方,則此線段與過檢測點的水平線不相交,跳過此次循環(huán)if (start.Y > point.Y && end.Y > point.Y)continue;if (start.Y <= point.Y && end.Y <= point.Y)continue;// 如果檢測點X坐標(biāo)小于線段起點和終點的X坐標(biāo)最小值,則此線段位于檢測點左側(cè),跳過此次循環(huán)if (point.X < Math.Min(start.X, end.X))continue;// 計算線段的斜率,并根據(jù)直線方程計算線段與過檢測點Y坐標(biāo)水平線的交點橫坐標(biāo)double slope = (end.Y - start.Y) / (end.X - start.X);double intersectX = start.X + (point.Y - start.Y) / slope;// 如果檢測點X坐標(biāo)大于等于交點橫坐標(biāo),則表示檢測點在線段的一側(cè),增加交叉次數(shù)if (point.X >= intersectX)crossings++;}// 根據(jù)奇偶性判斷:若交叉次數(shù)為奇數(shù),則認(rèn)為點在多段線內(nèi);否則點在多段線外return (crossings % 2) == 1;}//包含字符 出現(xiàn)次數(shù)public static int CountCharacterOccurrences(string str, string substring){if (string.IsNullOrEmpty(str) || string.IsNullOrEmpty(substring))return 0;int index = 0, count = 0;while ((index = str.IndexOf(substring, index)) != -1){count++;index += substring.Length; // 移動到下一個可能的位置}return count;}// GetCenterOfPolyline 是一個假設(shè)存在的方法,用于計算多邊形的中心點private Point3d GetCenterOfPolyline(Polyline polyline){double xSum = 0, ySum = 0, zSum = 0;for (int i = 0; i < polyline.NumberOfVertices; i++){Point3d vertex = polyline.GetPoint3dAt(i);xSum += vertex.X;ySum += vertex.Y;zSum += vertex.Z;}return new Point3d(xSum / polyline.NumberOfVertices, ySum / polyline.NumberOfVertices, zSum / polyline.NumberOfVertices);}
}

?//有需要cad二次開發(fā)可以私信進(jìn)行聯(lián)系
//感謝大家的點贊,收藏,轉(zhuǎn)發(fā),關(guān)注

???

http://www.risenshineclean.com/news/50574.html

相關(guān)文章:

  • 做教育app的網(wǎng)站有哪些百度最新版下載
  • 潮州網(wǎng)絡(luò)推廣seo課程培訓(xùn)班
  • 百度小程序登錄入口商品標(biāo)題seo是什么意思
  • 墾利網(wǎng)頁定制汕頭seo外包機構(gòu)
  • 學(xué)做美食視頻在哪個網(wǎng)站短信廣告投放軟件
  • 企業(yè)為什么要網(wǎng)站建設(shè)網(wǎng)推平臺有哪些
  • 廣告設(shè)計軟件手機版朝陽seo推廣
  • 正日商務(wù)做網(wǎng)站多少錢應(yīng)用商店下載安裝
  • 汕頭網(wǎng)站制作哪里好優(yōu)化網(wǎng)站標(biāo)題名詞解釋
  • 網(wǎng)頁制作工作網(wǎng)站提高工作效率的軟件
  • 好用的搜索引擎上海網(wǎng)站排名seo公司
  • 建網(wǎng)站的公司起什么名好江蘇seo技術(shù)教程
  • 惠州網(wǎng)站建設(shè)網(wǎng)站app拉新平臺
  • 衢州建筑裂縫加固seo推廣軟件排行榜
  • 如何做好網(wǎng)站建設(shè)的設(shè)計布局鄭州粒米seo顧問
  • 做爰全過程免費狐貍網(wǎng)站阿里巴巴國際貿(mào)易網(wǎng)站
  • 網(wǎng)站做配置文件的作用專業(yè)做網(wǎng)站設(shè)計
  • 圖片點開是網(wǎng)站怎么做在線外鏈推廣
  • 天津網(wǎng)站建設(shè)技術(shù)托管今日新聞大事件
  • 設(shè)計蘋果手機的網(wǎng)站長春seo代理
  • 網(wǎng)上購物商城網(wǎng)站建設(shè)畢業(yè)設(shè)計網(wǎng)絡(luò)平臺推廣運營有哪些平臺
  • 做網(wǎng)站的邊框素材重慶seo網(wǎng)絡(luò)推廣關(guān)鍵詞
  • 常州本地招聘網(wǎng)站怎么讓付費網(wǎng)站免費
  • gps定位網(wǎng)站建設(shè)網(wǎng)絡(luò)營銷策劃書總結(jié)
  • 網(wǎng)站建設(shè)預(yù)算策劃湖南seo優(yōu)化
  • 推廣網(wǎng)站怎么建設(shè)新東方線下培訓(xùn)機構(gòu)官網(wǎng)
  • 網(wǎng)頁設(shè)計html代碼大全菜鳥上海關(guān)鍵詞優(yōu)化公司bwyseo
  • 專業(yè)3合1網(wǎng)站建設(shè)知乎推廣渠道
  • 哈爾濱手機網(wǎng)站建設(shè)企業(yè)網(wǎng)站建站
  • asp.net 網(wǎng)站強制兼容性運行網(wǎng)站seo查詢站長之家