Chuyển đến nội dung
Diễn đàn CADViet

trivan77

Thành viên
  • Số lượng nội dung

    4
  • Đã tham gia

  • Lần ghé thăm cuối

Bài đăng được đăng bởi trivan77


  1. [CommandMethod("Sua_TKT")]
              public void sua_tkThep()
              {
                   Database db = doc.Database;

                   Editor ed = doc.Editor;

                   Transaction tr = db.TransactionManager.StartTransaction();

                   using (tr)
                   {
                        try
                        {
                             doc.LockDocument();
                             

                             BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                             BlockTableRecord btr = tr.GetObject(bt[thong_Ke_Thep.tenBlock], OpenMode.ForWrite) as BlockTableRecord;

                             foreach (ObjectId objId_loopVariable in btr.GetBlockReferenceIds(true, true))
                             {
                                  BlockReference bl = (BlockReference)tr.GetObject(objId_loopVariable, OpenMode.ForWrite);

     

     

                                   // ========================================================================
                                  if (bl.AttributeCollection.Count == 1)
                                  {
                                       //...
                                  }

     

                                  // ========================================================================

                                  if (bl.AttributeCollection.Count == 2)
                                  {
                                       Table table_1 = (Table)tr.GetObject(table.Id, OpenMode.ForWrite);


                                       table_1.Cells[soHang + 1, 1].Value = thong_Ke_Thep.soHieu;
                                       table_1.Cells[soHang + 1, 1].Alignment = cellAlign;

                                       //....

                                       

                                       AttributeCollection attCol = bl.AttributeCollection;

                                       foreach (ObjectId attId in attCol)
                                       {
                                            AttributeReference attRef = (AttributeReference)tr.GetObject(attId, OpenMode.ForRead);

                                            string tag = attRef.Tag;
                                            if (tag == "L1")
                                            {
                                                 attRef.UpgradeOpen();
                                                 attRef.TextString = L1;
                                                 //attRef.UpgradeOpen();
                                            }

                                            

                                            if (tag == "L2")
                                            {
                                                 attRef.UpgradeOpen();
                                                 attRef.MTextAttribute.Contents = L2;
                                                 //attRef.UpgradeOpen();

                                            }

                                            
                                            //attRef.UpdateMTextAttribute();
                                       }

                                  }

                             }
                             tr.Commit();
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception ex)
                        {
                             MessageBox.Show(ex.Message);
                        }

                   }


              }


  2. em đang tự học về code Autocad trong c#,.NET

    mọi người cho phép em hỏi 2 vấn đề như sau ạ:

    1. để thay đổi giá trị của block attribute thì mình sử dụng phương thức hay thay đổi thuộc tính nào ạ ? ( em đã lấy ra được đối tượng block )

    2. em đang dự định thực hiện code 2 phương thức movedim và cutdim, mọi người có thể gợi ý giúp em 1 chút ý tưởng được không ạ ( tác động đến thuộc tính, phương thức nào của đối tượng dimension,...), em đã lấy ra đối tượng dimension rồi ạ

    Em xin chân thành cảm ơn ạ

×