明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1719|回复: 5

[讨论][求助]用.netObject ARX 画完图在模型空间里显示问题

[复制链接]
发表于 2010-8-11 16:01:00 | 显示全部楼层 |阅读模式

我用.netObject ARX写代码 画图为什么在模型空间里不能看到,只能在布局里看到。

如果是比例问题,需要放大,但是怎么设置比例让他画完图正好以合适的比例显示在中央呢?

发表于 2010-8-11 16:13:00 | 显示全部楼层

你的代码呢?

 楼主| 发表于 2010-8-11 16:57:00 | 显示全部楼层

  public  void AddLine(System.Data.DataTable dt)
        {
            // Get the current document and database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;
                for (int j = 0; j < (dt.Rows.Count); j++)
                {
                    //  int useXAxis = 5;

                    if (!Convert.IsDBNull(dt.Rows[j]["p2.X"]) && !Convert.IsDBNull(dt.Rows[j]["p2.Y"]) && !Convert.IsDBNull(dt.Rows[j]["p2.Hight"]) &&
                        !Convert.IsDBNull(dt.Rows[j]["t1.X"]) && !Convert.IsDBNull(dt.Rows[j]["t1.Y"]) && !Convert.IsDBNull(dt.Rows[j]["t1.Hight"]))
                    {

                        // Create a line
                        Line acLine = new Line
                            (
                                        new Point3d
                                        (
                                            Convert.ToDouble(dt.Rows[j]["t1.X"]),
                                            Convert.ToDouble(dt.Rows[j]["t1.Y"]),
                                            Convert.ToDouble(dt.Rows[j]["t1.Hight"])
                                        ),
                                       new Point3d
                                       (
                                         Convert.ToDouble(dt.Rows[j]["p2.X"]),
                                         Convert.ToDouble(dt.Rows[j]["p2.Y"]),
                                         Convert.ToDouble(dt.Rows[j]["p2.Hight"])
                                        )
                           );

                        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();
            }
        }
     这是我的代码

 楼主| 发表于 2010-8-11 17:00:00 | 显示全部楼层
  1. public void AddPointAndSetPointStyle(System.Data.DataTable dtblPoint )
  2. {
  3. // Get the current document and database
  4. Document acDoc = Application.DocumentManager.MdiActiveDocument;
  5. Database acCurDb = acDoc.Database;
  6. // Start a transaction
  7. using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
  8. {
  9. // Open the Block table for read
  10. BlockTable acBlkTbl;
  11. acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
  12. OpenMode.ForRead) as BlockTable;
  13. // Open the Block table record Model space for write
  14. BlockTableRecord acBlkTblRec;
  15. acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
  16. OpenMode.ForWrite) as BlockTableRecord;
  17. for (int i = 0; i < dtblPoint.Rows.Count; i++)
  18. {
  19. if (!Convert.IsDBNull(dtblPoint.Rows[i]["X"]) && !Convert.IsDBNull(dtblPoint.Rows[i]["Y"]) && !Convert.IsDBNull(dtblPoint.Rows[i]["Hight"]))
  20. {
  21. // Create a point at (4, 3, 0) in Model space
  22. DBPoint acPoint = new DBPoint(new Point3d(
  23. Convert.ToDouble(dtblPoint.Rows[i]["X"]),
  24. Convert.ToDouble(dtblPoint.Rows[i]["Y"]),
  25. Convert.ToDouble(dtblPoint.Rows[i]["Hight"])
  26. ));
  27. acPoint.SetDatabaseDefaults();
  28. // Add the new object to the block table record and the transaction
  29. acBlkTblRec.AppendEntity(acPoint);
  30. acTrans.AddNewlyCreatedDBObject(acPoint, true);
  31. }
  32. }
  33. // Set the style for all point objects in the drawing
  34. acCurDb.Pdmode = 34;
  35. acCurDb.Pdsize = 1;
  36. // Save the new object to the database
  37. acTrans.Commit();
  38. }
  39. }
这是画点
发表于 2010-8-11 17:27:00 | 显示全部楼层
哦,你可以在图形画完后调Cad的zoom命令
 楼主| 发表于 2010-9-14 14:58:00 | 显示全部楼层

怎么设置图纸的比例尺

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 01:25 , Processed in 0.172232 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表