thinhtutn
-
Số lượng nội dung
16 -
Đã tham gia
-
Lần ghé thăm cuối
Bài đăng được đăng bởi thinhtutn
-
-
AutoCAD .NET
trong Lập trình khác
Cảm ơn bác gia_bach rất nhiều.
-
AutoCAD .NET
trong Lập trình khác
Bác gia_bach chỉ em cách lấy số và chữ từ màn hình với. Em cảm ơn bác!!!
-
AutoCAD .NET
trong Lập trình khác
Em có code thế này
Public Class Class1 Sub Add_Line(ByVal X1, ByVal Y1, ByVal X2, ByVal Y2) '' Get the current document and database Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database '' Start a transaction Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() '' Open the Block table for read Dim acBlkTbl As BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, DatabaseServices.OpenMode.ForRead) '' Open the Block table record Model space for write Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), DatabaseServices.OpenMode.ForWrite) '' Create a line that starts at 5,5 and ends at 12,3 Dim acLine As Line = New Line(New Point3d(X1, Y1, 0), New Point3d(X2, Y2, 0)) acLine.SetDatabaseDefaults() '' Add the new object to the block table record and the transaction acBlkTblRec.AppendEntity(acLine) acTrans.AddNewlyCreatedDBObject(acLine, True) '' Save the new object to the database acTrans.Commit() End Using End Sub <CommandMethod("caotrinh")> Public Sub Dien_cao_trinh() '' Get the current database and start the Transaction Manager Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Dim P1 As PromptPointResult Dim P2 As PromptPointResult Dim pPtOpts As PromptPointOptions = New PromptPointOptions("") ''Nhap ty le ban ve Dim tlvOpts As PromptDoubleOptions = New PromptDoubleOptions(vbLf & "Nhập tỷ lệ khung bản vẽ: (1/...10, 20, 50, 100, ...): ") Dim tlbv As PromptDoubleResult = acDoc.Editor.GetDouble(tlvOpts) Dim TLV = tlbv.Value / 1000 '' Prompt for the start point pPtOpts.Message = vbLf & "Pick điểm mốc: " P1 = acDoc.Editor.GetPoint(pPtOpts) '' Exit if the user presses ESC or cancels the command If P1.Status = PromptStatus.Cancel Then Exit Sub '' Nhap cao do moc Dim CDMOC_Opts As PromptDoubleOptions = New PromptDoubleOptions(vbLf & "Nhập cao độ mốc: ") Dim CDMOC As PromptDoubleResult = acDoc.Editor.GetDouble(CDMOC_Opts) While CDMOC.Value + P1.Value.Y <> 0 '' Prompt for the end point pPtOpts.Message = vbLf & "Pick điểm điền cao độ: " pPtOpts.UseBasePoint = True pPtOpts.BasePoint = P1.Value P2 = acDoc.Editor.GetPoint(pPtOpts) If P2.Status = PromptStatus.Cancel Then Exit Sub '' Start a transaction Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable Dim acBlkTblRec As BlockTableRecord '' Open Model space for write acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, DatabaseServices.OpenMode.ForRead) acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), DatabaseServices.OpenMode.ForWrite) Dim pKeyOpts As PromptKeywordOptions = New PromptKeywordOptions("") pKeyOpts.Message = vbLf & "Chọn hướng điền " pKeyOpts.Keywords.Add("Trai") pKeyOpts.Keywords.Add("Phai") pKeyOpts.AllowNone = False Dim pKeyRes As PromptResult = acDoc.Editor.GetKeywords(pKeyOpts) If pKeyRes.Status = PromptStatus.Cancel Then Exit Sub If pKeyRes.StringResult = "Phai" Then '' Vẽ ký hiệu cao trình Add_Line(P2.Value.X, P2.Value.Y, P2.Value.X + 3.6 * TLV, P2.Value.Y) Add_Line(P2.Value.X + 3 * TLV, P2.Value.Y, P2.Value.X + 3 * TLV, P2.Value.Y + 7.5 * TLV) Add_Line(P2.Value.X + 1.6 * TLV, P2.Value.Y + 3.8 * TLV, P2.Value.X + 10.6 * TLV, P2.Value.Y + 3.8 * TLV) Add_Line(P2.Value.X + 3.0 * TLV, P2.Value.Y, P2.Value.X + 2.6 * TLV, P2.Value.Y + 2 * TLV) Add_Line(P2.Value.X + 2.6 * TLV, P2.Value.Y + 2 * TLV, P2.Value.X + 3.4 * TLV, P2.Value.Y + 2 * TLV) Add_Line(P2.Value.X + 3.4 * TLV, P2.Value.Y + 2 * TLV, P2.Value.X + 3 * TLV, P2.Value.Y) '' Điền cao trình Dim acText As DBText = New DBText() acText.SetDatabaseDefaults() acText.Position = New Point3d(P2.Value.X + 3.9 * TLV, P2.Value.Y + 4.1 * TLV, 0) acText.Height = TLV * 2 acText.TextString = Format(CDMOC.Value - P1.Value.Y + P2.Value.Y, "00.00") ''ChuoiRes.StringResult acBlkTblRec.AppendEntity(acText) acTrans.AddNewlyCreatedDBObject(acText, True) If P2.Status = PromptStatus.Cancel Then Exit Sub Else '' Vẽ ký hiệu cao trình Add_Line(P2.Value.X, P2.Value.Y, P2.Value.X - 3.6 * TLV, P2.Value.Y) Add_Line(P2.Value.X - 3 * TLV, P2.Value.Y, P2.Value.X - 3 * TLV, P2.Value.Y + 7.5 * TLV) Add_Line(P2.Value.X - 1.6 * TLV, P2.Value.Y + 3.8 * TLV, P2.Value.X - 10.6 * TLV, P2.Value.Y + 3.8 * TLV) Add_Line(P2.Value.X - 3.0 * TLV, P2.Value.Y, P2.Value.X - 2.6 * TLV, P2.Value.Y + 2 * TLV) Add_Line(P2.Value.X - 2.6 * TLV, P2.Value.Y + 2 * TLV, P2.Value.X - 3.4 * TLV, P2.Value.Y + 2 * TLV) Add_Line(P2.Value.X - 3.4 * TLV, P2.Value.Y + 2 * TLV, P2.Value.X - 3 * TLV, P2.Value.Y) '' Điền cao trình Dim acText As DBText = New DBText() acText.SetDatabaseDefaults() acText.HorizontalMode = TextHorizontalMode.TextRight acText.AlignmentPoint = New Point3d(P2.Value.X - 3.9 * TLV, P2.Value.Y + 4.1 * TLV, 0) acText.Height = TLV * 2 acText.TextString = Format(CDMOC.Value - P1.Value.Y + P2.Value.Y, "00.00") acBlkTblRec.AppendEntity(acText) acTrans.AddNewlyCreatedDBObject(acText, True) If P2.Status = PromptStatus.Cancel Then Exit Sub End If '' Commit the changes and dispose of the transaction acTrans.Commit() End Using End While End Sub End ClassCác bác thêm giúp em phần cao độ mốc nếu không nhập trực tiếp thì có thể lấy giá trị trên màn hình với.
-
AutoCAD .NET
trong Lập trình khác
các bác hướng dẫn cho em cách đổi từ chuỗi sang dạng số thập phân và từ số thập phân sang dạng chuỗi với ạ. Em giờ mới đang bắt đầu ngâm cứu.
P/S: Thêm cả phần điền số thập phân với ạ.
-
-
Đây là đoạn code viết text
Set caodo = AcadApplication.ActiveDocument.ModelSpace.AddText(noidung, x, hchu) caodo.Alignment = acAlignmentMiddleCenter caodo.TextAlignmentPoint = xgocnghieng = 0 / 180 * 3.14159caodo.Rotate x, gocnghiengcaodo.Update
noidung: là nội dung
x: tọa độ
hchu; chiều cao
Em làm được rồi. Cám ơn bác!
-
Các bác cho em hỏi: cho để text nghiêng theo một góc thì làm thế nào? Ví dụ như khi điền độ dốc đường chẳng hạn.
-
Em thấy của bác Giabach và bác thehost31 đều không chạy được trên Acad 2005 và Acad 2006. Các bác có thể sửa được không.
-
Không bác nào trả lời em sao.
-
Em thấy bản 2.0 và 2.1 này của bác in bên layout thì được, nếu in bên Model khi Preview thì chỉ hiện lên trang trắng. Bác sửa lại để in được cả model và layout được không.
-
Các bác có thể thêm phần chọn text ghi kết quả không
-
Các bác có thể bổ xung thêm phần nếu không chọn số có sẵn trong bản vẽ thì nhập số từ bàn phím được không?
-
Cái này không chạy được trên CAD2005 phải không bác. Em load ở Cad2005 nó toàn báo thế này: "netload Cannot load assembly. Error details: Could not load file or assembly 'acmgd, Version=18.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
-
Có bác nào giúp em với! Híc :)
-
Các bác cho em hỏi cái: khi ép khung trong layout thì dùng lệnh gì mà pick 2 điểm trên hình vẽ thì hình vẽ đó sẽ vừa kín khung viewports nhỉ? Ai biết chỉ em với.
Lỗi crosshair, pickbox
trong Sử dụng AutoCAD
Đã đăng · Trả lời báo cáo
Các bác chỉ em cách giải quyết trường hợp layout không thấy con trỏ và crosshair với.