.NET CAD二次開發學習 直線畫矩形並轉換成組

来源:https://www.cnblogs.com/yannisCad/archive/2019/04/09/10677558.html
-Advertisement-
Play Games

主要代碼: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using GrxCAD.Runtime;using GrxCAD ...


主要代碼:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GrxCAD.Runtime;
using GrxCAD.ApplicationServices;
using GrxCAD.EditorInput;
using GrxCAD.Geometry;
using GrxCAD.DatabaseServices;
using GrxCAD.Windows;

namespace ArxFirstTest
{
public class XRect
{

private Point3d StartPoint;
private Point3d EndPoint;
private double width;

public void XrecPic()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor editor = doc.Editor;
Database db = doc.Database;
PromptPointOptions promptPoint1 = new PromptPointOptions("\n請指定起點<退出>");
PromptPointResult pointResult1 = editor.GetPoint(promptPoint1);
PromptPointOptions promptPoint2 = new PromptPointOptions("\n請指定終點<退出>");
PromptPointResult pointResult2 = editor.GetPoint(promptPoint2);
PromptDoubleOptions pDoubleOptions = new PromptDoubleOptions("\n請輸入寬度<退出>");
PromptDoubleResult pDoubleRes = editor.GetDouble(pDoubleOptions);
if (pointResult1.Status == PromptStatus.OK && pointResult2.Status == PromptStatus.OK && pDoubleRes.Value > 0)
{
using (Transaction trans = doc.TransactionManager.StartTransaction())
{
StartPoint = pointResult1.Value;
EndPoint = pointResult2.Value;
width = pDoubleRes.Value;
Line line = new Line();
line.StartPoint = StartPoint;
line.EndPoint = EndPoint;
DBObjectCollection dboj = line.GetOffsetCurves(width / 2);
DBObjectCollection dboj1 = line.GetOffsetCurves(width / 2 - width);
Line line1 = (Line)dboj[0];
Line line2 = (Line)dboj1[0];
Line line3 = new Line();
Line line4 = new Line();
line3.StartPoint = line1.StartPoint;
line3.EndPoint = line2.StartPoint;
line4.StartPoint = line1.EndPoint;
line4.EndPoint = line2.EndPoint;
ObjectId idModelSpace = SymbolUtilityServices.GetBlockModelSpaceId(db);
BlockTableRecord btr = trans.GetObject(idModelSpace, OpenMode.ForWrite) as BlockTableRecord;
btr.AppendEntity(line1);
btr.AppendEntity(line2);
btr.AppendEntity(line3);
btr.AppendEntity(line4);
trans.AddNewlyCreatedDBObject(line1, true);
trans.AddNewlyCreatedDBObject(line2, true);
trans.AddNewlyCreatedDBObject(line3, true);
trans.AddNewlyCreatedDBObject(line4, true);
Entity ent1 = (Entity)line1;
Entity ent2 = (Entity)line2;
Entity ent3 = (Entity)line3;
Entity ent4 = (Entity)line4;
Group group = new Group();
group.Append(ent1.ObjectId);
group.Append(ent2.ObjectId);
group.Append(ent3.ObjectId);
group.Append(ent4.ObjectId);
DBDictionary groupdic = trans.GetObject(db.GroupDictionaryId,OpenMode.ForWrite) as DBDictionary;
group.Selectable = true;
groupdic.SetAt(group.Name, group);
trans.AddNewlyCreatedDBObject(group, true);
trans.Commit();

}

}
else
{
Application.ShowAlertDialog("選擇或者輸入有誤,請重新輸入");
return;

}

}
}
}

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • ...
  • 指針很簡單 引子 學電腦語言,首先推薦C語言.無論是數據結構還是演算法,站在C語言的角度,會讓我們理解的更加清晰透徹. 但是,指針不太"友好",讓很多人抓狂,頭疼.不少人選擇了放棄,繞行.百度上有千千萬個解決方法,而我們放棄的理 由和簡單,路在腳下,向前還?是向後? C語言之所以經久不衰,就是因為指 ...
  • 每種方法中上面的是Excel的行數,下麵的是Excel的列數。方法七:經過加工修改已經可以讀出來的是有效數據行 using Excel = Microsoft.Office.Interop.Excel;//Excel表讀寫 Excel.Application app = new Excel.Appl ...
  • 原文鏈接:https://www.entityframeworktutorial.net/code-first/stringlength-dataannotations-attribute-in-code-first.aspx StringLength特性可以應用於實體的string類型的屬性上,它 ...
  • 原文鏈接:https://www.entityframeworktutorial.net/code-first/maxlength-minlength-dataannotations-attribute-in-code-first.aspx MaxLength特性指定了屬性的值所允許的最大值,然後在 ...
  • 最近在學WebSocket,服務端需要監聽多個WebSocket客戶端發送的消息。 開始的解決方法是每個WebSocket客戶端都添加一個線程進行監聽,代碼如下: /// <summary> /// 監聽埠 創建WebSocket /// </summary> /// <param name="h ...
  • 備註:本人使用開發工具:VS2017,.NET Core 2.2,其中VS2017原本自帶2.1,我單獨從官網下載了2.2的程式集安裝包,但是沒有下配套的運行環境,運行項目時出了一個問題。 以下是我在發佈Core項目後部署到IIS後運行時遇到的一些問題: 1-發佈設置: 在發佈過程中,項目一直還原n ...
  • [CommandMethod("CBline")] //對稱畫線 public void CBline() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor edit = doc.Editor; Databa ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...