www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawPolyline 接口

多段线类型

IDL
[ object, uuid(0D5B311A-21E4-44B7-B6EB-71489F920077), dual, nonextensible, helpstring("IMxDrawPolyline interface"), pointer_default(unique) ]
interface IMxDrawPolyline : IMxDrawCurve;

MxDrawPolyline.idl

例如:C# 绘制一个3dPL线,并设置它的Z值.

                      // 开始绘制
                                axMxDrawX1.PathMoveTo(10, 10);
                                axMxDrawX1.PathLineTo(200, 200);

                                Int64 lId = axMxDrawX1.DrawPathToPolyline();

                                // 得到新绘制的PL线对象
                                MxDrawPolyline pl = (MxDrawPolyline)axMxDrawX1.ObjectIdToObject(lId);
                    //得到它的当前类型
                    //             MxDrawResbuf ret = pl.GetProp("Type");
                    //             MessageBox.Show(ret.AtLong(0).ToString());           
                    //PL线的类型,可以是如下3个值 
                    //          enum  PolylineType
                    //          {
                    //              kLwPolyline = 0,
                    //              k2dPolyline = 1,
                    //              k3dPolyline = 2
                    //          };

                                MxDrawResbuf param = new MxDrawResbuf();
                                // 把PL线的类设置成k3dPolyline
                                param.AddLong(2);
                                pl.SetProp("Type", param);

   
                                // 设置PL线的z值。

                                MxDrawPoint pt = pl.GetPointAt(0);
                                pt.z = 100;
                                pl.SetPointAt(0, pt);

                                //
                                pt = pl.GetPointAt(1);
                                pt.z = 200;
                                pl.SetPointAt(1, pt);

 

例如: C#得到多线的端点,并成填充对象。

        private void TestFill(String sHandle)
        {
            MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();
            MxDrawMcDbObject obj =  database.HandleToObject(sHandle);
            if (obj == null)
                return;

            if (obj is MxDrawPolyline)
            {
                MxDrawPolyline poly = (MxDrawPolyline)obj;
                int i = 0;
                for (; i < poly.NumVerts; i++)
                {
                    MxDrawPoint pt = (MxDrawPoint)poly.GetPointAt(i);
                    double dBulge = poly.GetBulgeAt(i);
                    if (i == 0)
                        axMxDrawX1.PathMoveTo(pt.x, pt.y);
                    else
                        axMxDrawX1.PathLineToEx(pt.x, pt.y, 0.0, 0.0, dBulge);
                }

                if (i >= 3)
                {
                    axMxDrawX1.PathMakeClosed();
                    axMxDrawX1.DrawPathToHatch(1.0);
                }
            }

        }

 

例如: JS 通过打碎函数,得到pl线的坐标信息

            function GetPolyline() {
                var ent = mxOcx.GetEntity("选择pl线:");
                if (ent == null) {
                    return;
                }
                if (ent.ObjectName != "McDbPolyline") {
                    return;
                }

                var param = mxOcx.NewResbuf();
                param.AddObjectId(ent.ObjectID);

                var ret = mxOcx.CallEx('Mx_Explode', param);

                var jj = 1;
                for(;jj < ret.Count;jj++) {

                    var tmp = ret.AtObject(jj);

                    if (tmp.ObjectName == "McDbLine") {
                        //  是个直线。 得到直线的开始点坐标,和结束点坐标。
                        var spt = tmp.StartPoint;
                        var ept = tmp.EndPoint;
                        alert(spt.x)
                        alert(spt.y)

                        alert(ept.x)
                        alert(ept.y)

                    }
                    else if (tmp.ObjectName == "McDbArc") {
                        // 是个圆弧
                        var cen = tmp.Center;
                        var sAng = tmp.StartAngle;
                        var eAng = tmp.EndAngle;
                        var r = tmp.Radius;
                        alert(r);
                    }
                    tmp.Erase();
                 }


            }

 

例如:得到pl线所在区域里,离区域中心位置最近的文本。

            MxDrawResbuf ret = pl.GetProp("FindText");

            if(ret.Count != 0)
            {
                MxDrawMcDbObject obj = ret.AtObject(0);
                if(obj == null)
                    continue;

                axMxDrawX1.TwinkeEnt (obj.ObjectID);
            }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!