• 使用规则重定义使civil 3d标签与视图平行


    昨天同事提出了这样一个需求,

    要让曲面的点位高程标签与屏幕平行,

    以便于查看,

    如下图:

    其实这个实现起来很简单:

    不知道大家对这个教程是否熟悉,

    如果熟悉的话,

    问题就相当简单。

    直接修改样例代码,

    几行代码就搞定了。

        public class LabelOverrule : DrawableOverrule
        {
            public override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.Drawable drawable, Autodesk.AutoCAD.GraphicsInterface.WorldDraw wd)
            {
                return false;
            }
    
            public override void ViewportDraw(Autodesk.AutoCAD.GraphicsInterface.Drawable drawable, Autodesk.AutoCAD.GraphicsInterface.ViewportDraw vd)
            {
                SurfaceElevationLabel label = (SurfaceElevationLabel)drawable;
                Point3d org = label.LabelLocation;
                Matrix3d m = Matrix3d.PlaneToWorld(new Plane(org, vd.Viewport.ViewDirection)) *
                    Matrix3d.WorldToPlane(new Plane(org, label.GetPlane().Normal)) * Matrix3d.Rotation(-label.RotationAngle, label.GetPlane().Normal, org);
    
                vd.Geometry.PushModelTransform(m);
                base.ViewportDraw(drawable, vd);
                vd.Geometry.PopModelTransform();
            }
    
            public override int SetAttributes(Autodesk.AutoCAD.GraphicsInterface.Drawable drawable, Autodesk.AutoCAD.GraphicsInterface.DrawableTraits traits)
            {
                return (base.SetAttributes(drawable, traits)|2048);
            }
        }
    

    这里需要注意的是,

    标签样式中“方向引用”需要设置为“世界坐标系”,

    否则标签有些时候显示会不符合需求。

    如何调用上面的代码,

    还可以参照这个链接中文章。

  • 相关阅读:
    jQuery 遍历函数 ,javascript中的each遍历
    定时器:右下角滑动信息通知
    nopad++将制表符替换为换行符
    使用git提交远程仓库
    (转)解决windows解决windows 7 部分程序图标显示不正常的问题
    设置gvim的字体大小
    mysql乱码
    (转)notepad++去重
    查看linux硬件的信息
    虚拟机安装centos6.5出现Error processing drive:pci-0000:00:10-scsi-0:0:0:0问题
  • 原文地址:https://www.cnblogs.com/myzw/p/13369887.html
Copyright © 2020-2023  润新知