乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 60|回复: 3

如何使用Jigs动态旋转实体?

[复制链接]

16

主题

48

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
112
发表于 2011-9-29 08:02:00 | 显示全部楼层 |阅读模式
用了置顶里的方法
public void RotateEntity()
    {
      Document doc =
        Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      Database db = doc.Database;

      // First we prompt for the entity to rotate

      PromptEntityOptions peo =
        new PromptEntityOptions(
          "\nSelect entity to rotate: "
        );
      PromptEntityResult per =
        ed.GetEntity(peo);

      if (per.Status == PromptStatus.OK)
      {
        Transaction tr =
          db.TransactionManager.StartTransaction();
        using (tr)
        {
          DBObject obj =
            tr.GetObject(per.ObjectId, OpenMode.ForRead);
          Entity ent = obj as Entity;

          // Use the origin as the default center

          Point3d rotationPoint = Point3d.Origin;

          // If the entity is a polyline,
          // assume it is rectangular and then
          // set the rotation point as its center

          Polyline pl = obj as Polyline;
          if (pl != null)
          {
            LineSegment3d ps0 =
              pl.GetLineSegmentAt(0);
            LineSegment3d ps1 =
              pl.GetLineSegmentAt(1);
            Vector3d vec =
              ((ps0.EndPoint - ps0.StartPoint) / 2.0) +
              ((ps1.EndPoint - ps1.StartPoint) / 2.0);
            rotationPoint = pl.StartPoint + vec;
          }

          // Get the base rotation angle stored with the
          // entity, if there was one (default is 0.0)

          double baseAngle = GetStoredRotation(obj);

          if (ent != null)
          {
            // Get the current UCS, to pass to the Jig

            Matrix3d ucs =
              ed.CurrentUserCoordinateSystem;

            // Create our jig object

            RotateJig jig =
              new RotateJig(
                ent,
                rotationPoint,
                baseAngle,
                ucs
              );

            PromptResult res = ed.Drag(jig);
            if (res.Status == PromptStatus.OK)
            {
              // Get the overall rotation angle
              // and dispose of the temp clone

              double newAngle = jig.GetRotation();
              jig.GetEntity().Dispose();

              // Rotate the original entity

              Matrix3d trans =
                Matrix3d.Rotation(
                  newAngle - baseAngle,
                  ucs.CoordinateSystem3d.Zaxis,
                  rotationPoint);

              ent.UpgradeOpen();
              ent.TransformBy(trans);

              // Store the new rotation as XData

              SetStoredRotation(ent, newAngle);
            }
          }
          tr.Commit();
        }
      }
    }
但没有动态旋转效果,并且运行到ent.UpgradeOpen() 就退出了,我的实体是一个块图形
回复

使用道具 举报

16

主题

48

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
112
发表于 2011-9-29 15:21:00 | 显示全部楼层
没人知道么,谁有成功的例子啊?
回复

使用道具 举报

16

主题

48

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
112
发表于 2011-9-29 16:54:00 | 显示全部楼层
问下置顶里Jigs动态旋转实体是跟随鼠标移动而旋转么?
回复

使用道具 举报

16

主题

48

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
112
发表于 2011-9-29 17:10:00 | 显示全部楼层
为什么用RECTANG创建的矩形就可以,块图形就不行了呢,求高手帮帮忙啊!!!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-15 17:26 , Processed in 2.435010 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表