读取填充属性,并设置到另一个新建的填充.
C#开发|大少爷|2017-07-27 14:51
-
回答:
MxDrawEntity ent = (MxDrawEntity)axMxDrawX1.GetEntity("hatch"); if (ent == null) return; if (!(ent is MxDrawHatch) ) { return; } MxDrawHatch hatch = (MxDrawHatch)ent; MxDrawHatch newHatch = new MxDrawHatch(); // 读取选择到填充对象数据,把这个数据传给新建的newHathc对象。 newHatch.PatternAngle = hatch.PatternAngle; // 循环得到填充边数据. for (Int32 i = 0; i < hatch.NumLoops; i++) { if (!hatch.LoopTypeIsPolyline(i)) { // 暂不支持曲线类型的边界. continue; } Int32 iLootType = hatch.LoopTypeAt(i); MxDrawResbuf loop = hatch.GetLoopAt(i); if(loop == null) continue; // 下面可以得每个点的坐标,凸度. for (Int32 j = 0; j + 1< loop.Count; ) { MxDrawPoint pt = loop.AtPoint(j); double dBulge = loop.AtDouble(j + 1); j += 2; } // 把得到loop设置给新对象. newHatch.AppendLoop(iLootType, loop); } // newHatch.Elevation = hatch.Elevation; // 读取图案定义数据. for (Int32 i = 0; i < hatch.NumPatternDefinitions(); i++) { double Angle = 0.0, baseX = 0.0, baseY = 0.0, offsetX = 0.0, offsetY = 0.0; MxDrawResbuf defData = hatch.GetPatternDefinitionAt(i, out Angle, out baseX, out baseY, out offsetX, out offsetY); if (defData == null) continue; // 下面可以得每个图案定义线型数据 。 for (Int32 j = 0; j + 1 < defData.Count; j++ ) { double dDashe = defData.AtDouble(j); } newHatch.AddPatternDefinition(Angle,baseX,baseY,offsetX,offsetY,defData); } // newHatch.PatternType = hatch.PatternType; newHatch.PatternName = hatch.PatternName; newHatch.PatternScale = hatch.PatternScale; newHatch.PatternSpace = hatch.PatternSpace; newHatch.PatternDouble = hatch.PatternDouble; newHatch.HatchStyle = hatch.HatchStyle; newHatch.HatchObjectType = hatch.HatchObjectType; newHatch.GradientType = hatch.GradientType; newHatch.GradientName = hatch.GradientName; newHatch.GradientAngle = hatch.GradientAngle; newHatch.GradientOneColorMode = hatch.GradientOneColorMode; newHatch.ShadeTintValue = hatch.ShadeTintValue; // 把新的填充对象增加当前空间。 axMxDrawX1.DrawEntity(newHatch);