Querying for XCLIP information inside AutoCAD using .NET  这里下面观众讨论了

How do I determine if an x-clip boundary is inverted?

看起来Autodesk忘记了通过API公开此设置,或将其包含在DXF输出中.
也许您可以通过调用 SpatialFilter.ClipVolumeIntersectsExtents() 来确定它,它的内容完全在边界之内.
该设置通过 DwgOutFields() 提交给DWG文件管理器,因此,如果所有其他操作均失败,则可以编写一个自定义AcDbDwgFiler来捕获该设置。

首先说明一下,根据以上的帖子,我们会得到一个消息是,桌子并没有封装好cad的块裁剪边界翻转部分.

然后我翻了翻api,在Acad2015版本上面是已经加了一个 SpatialFilter.Inverted 这个函数.

而我们低版本需要的就是重写出一个 Inverted ..

最后要进行刷新.

这样就完成了.

但是要注意下面的函数,它们只是个例子,没有提供撤销回滚的时候要刷新的操作...这个部分大家自己自行制作.

命令主函数部分:

    public static partial class Command_jjMoveBlockCropBoundary
{
//选择图块,进行反向裁剪
[CommandMethod("test", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Session)]
public static void test()
{
Database db = HostApplicationServices.WorkingDatabase;//当前的数据库
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
var peo = new PromptEntityOptions(Environment.NewLine + "点选图块:")
{
AllowObjectOnLockedLayer = false,
AllowNone = false
};
var gt = ed.GetEntity(peo);
if (gt.Status != PromptStatus.OK)
{
return;
}
using (Application.DocumentManager.MdiActiveDocument.LockDocument())//锁文档 用CommandFlags.Session就要锁,否则eLockViolation
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
var ent = tr.GetObject(gt.ObjectId, OpenMode.ForRead);
if (ent is BlockReference acBlkRef)
{
SpatialFilter blockBoundaryInfo = BlockBoundaryInfo(acBlkRef, tr);//块裁剪边界信息
if (blockBoundaryInfo != null)
{
//直接设置为反向
blockBoundaryInfo.UpgradeOpen();
#if false //这个在2015以上版本有,但是下面的操作是通用的
blockBoundaryInfo.Inverted = !blockBoundaryInfo.Inverted;
#endif
var fa = blockBoundaryInfo.Inverted(out XmDwgFiler xmDwgFiler);
blockBoundaryInfo.SetInverted(xmDwgFiler); blockBoundaryInfo.DowngradeOpen(); acBlkRef.UpgradeOpen();
acBlkRef.RecordGraphicsModified(true);//记录图元已修改,这个之前要ent.UpgradeOpen()
acBlkRef.DowngradeOpen();
}
}
tr.Commit();
}
}
}

判断和设置部分.

        /// <summary>
/// 边界是否为反向裁剪
/// </summary>
/// <param name="spatialFilter">裁剪信息</param>
/// <returns></returns>
public static bool Inverted(this SpatialFilter spatialFilter, out XmDwgFiler xmDwgFiler)
{
xmDwgFiler = new XmDwgFiler();
spatialFilter.DwgOut(xmDwgFiler);
var f = xmDwgFiler.UInt16List[];
if (f != )
{
return false;
}
else
{
return true;
}
} /// <summary>
/// 设定反向裁剪
/// </summary>
/// <param name="spatialFilter">裁剪数据</param>
/// <param name="xmDwgFiler">原始数据</param>
/// <returns></returns>
public static void SetInverted(this SpatialFilter spatialFilter, XmDwgFiler xmDwgFiler)
{
if (xmDwgFiler.UInt16List[] == )
{
xmDwgFiler.UInt16List[] = ;
}
else
{
xmDwgFiler.UInt16List[] = ;
}
spatialFilter.DwgIn(xmDwgFiler);
}

继承DwgFiler的类,超长的部分...要注意,我并没有完美的写好这个类,它可能不在所有的cad版本上通用,详情自己去设置....

    public class XmDwgFiler : DwgFiler
{
public FilerType m_FilerType;
public ErrorStatus m_FilerStatus; public
#if AC2008
int
#else
long
#endif
m_Position; //保存数据属性
public List<IntPtr> AddressList { get; set; }
public int AddressListPt = ;
public List<byte[]> BinaryChunkList { get; set; }
public int BinaryChunkListPt = ;
public List<bool> BooleanList { get; set; }
public int BooleanListPt = ;
public List<byte> ByteList { get; set; }
public int ByteListPt = ;
public List<byte[]> BytesList { get; set; }
public int BytesListPt = ;
public List<double> DoubleList { get; set; }
public int DoubleListPt = ;
public List<Handle> HandleList { get; set; }
public int HandleListPt = ;
public List<ObjectId> HardOwnershipIdList { get; set; }
public int HardOwnershipIdListPt = ;
public List<ObjectId> HardPointerIdList { get; set; }
public int HardPointerIdListPt = ;
public List<short> Int16List { get; set; }
public int Int16ListPt = ;
public List<int> Int32List { get; set; }
public int Int32ListPt = ;
public List<long> Int64List { get; set; }
public int Int64ListPt = ;
public List<Point2d> Point2dList { get; set; }
public int Point2dListPt = ;
public List<Point3d> Point3dList { get; set; }
public int Point3dListPt = ;
public List<Scale3d> Scale3dList { get; set; }
public int Scale3dListPt = ;
public List<ObjectId> SoftOwnershipIdList { get; set; }
public int SoftOwnershipIdListPt = ;
public List<ObjectId> SoftPointerIdList { get; set; }
public int SoftPointerIdListPt = ;
public List<string> StringList { get; set; }
public int StringListPt = ;
public List<ushort> UInt16List { get; set; }
public int UInt16ListPt = ;
public List<uint> UInt32List { get; set; }
public int UInt32ListPt = ;
public List<ulong> UInt64List { get; set; }
public int UInt64ListPt = ;
public List<Vector2d> Vector2dList { get; set; }
public int Vector2dListPt = ;
public List<Vector3d> Vector3dList { get; set; }
public int Vector3dListPt = ; //构造函数
public XmDwgFiler()
{
m_FilerType = FilerType.CopyFiler;
m_FilerStatus = ErrorStatus.OK;
m_Position = ;
AddressList = new List<IntPtr>();
BinaryChunkList = new List<byte[]>();
BooleanList = new List<bool>();
ByteList = new List<byte>();
BytesList = new List<byte[]>();
DoubleList = new List<double>();
HandleList = new List<Handle>();
HardOwnershipIdList = new List<ObjectId>();
HardPointerIdList = new List<ObjectId>();
Int16List = new List<short>();
Int32List = new List<int>();
Int64List = new List<long>();
Point2dList = new List<Point2d>();
Point3dList = new List<Point3d>();
Scale3dList = new List<Scale3d>();
SoftOwnershipIdList = new List<ObjectId>();
SoftPointerIdList = new List<ObjectId>();
StringList = new List<string>();
UInt16List = new List<ushort>();
UInt32List = new List<uint>();
UInt64List = new List<ulong>();
Vector2dList = new List<Vector2d>();
Vector3dList = new List<Vector3d>();
} public override IntPtr ReadAddress()
{
if (AddressList.Count() == )
{
return new IntPtr();
}
return AddressList[AddressListPt++];
} public override byte[] ReadBinaryChunk()
{
if (BinaryChunkList.Count() == )
{
return null;
}
return BinaryChunkList[BinaryChunkListPt++];
} public override bool ReadBoolean()
{
if (BooleanList.Count() == )
{
return false;
}
return BooleanList[BooleanListPt++];
} public override byte ReadByte()
{
if (ByteList.Count() == )
{
return ;
}
return ByteList[ByteListPt++];
} public override void ReadBytes(byte[] value)
{
if (ByteList.Count() == )
{
return;
}
value = new byte[BytesList[BytesListPt].Length];
BytesList[BytesListPt++].CopyTo(value, );
} public override double ReadDouble()
{
if (DoubleList.Count() == )
{
return ;
}
return DoubleList[DoubleListPt++];
} public override Handle ReadHandle()
{
if (HandleList.Count() == )
{
return new Handle();
}
return HandleList[HandleListPt++];
} public override ObjectId ReadHardOwnershipId()
{
if (HardOwnershipIdList.Count() == )
{
return new ObjectId();
}
return HardOwnershipIdList[HardOwnershipIdListPt++];
} public override ObjectId ReadHardPointerId()
{
if (HardPointerIdList.Count() == )
{
return new ObjectId();
}
return HardPointerIdList[HardPointerIdListPt++];
} public override short ReadInt16()
{
if (Int16List.Count() == )
{
return ;
}
return Int16List[Int16ListPt++];
} public override int ReadInt32()
{
if (Int32List.Count() == )
{
return ;
}
return Int32List[Int32ListPt++];
} public override Point2d ReadPoint2d()
{
if (Point2dList.Count() == )
{
return new Point2d();
}
return Point2dList[Point2dListPt++];
} public override Point3d ReadPoint3d()
{
if (Point3dList.Count() == )
{
return new Point3d();
}
return Point3dList[Point3dListPt++];
} public override Scale3d ReadScale3d()
{
if (Scale3dList.Count() == )
{
return new Scale3d();
}
return Scale3dList[Scale3dListPt++];
} public override ObjectId ReadSoftOwnershipId()
{
if (SoftOwnershipIdList.Count() == )
{
return new ObjectId();
}
return SoftOwnershipIdList[SoftOwnershipIdListPt++];
} public override ObjectId ReadSoftPointerId()
{
if (SoftPointerIdList.Count() == )
{
return new ObjectId();
}
return SoftPointerIdList[SoftPointerIdListPt++];
} public override string ReadString()
{
if (StringList.Count() == )
{
return null;
}
return StringList[StringListPt++];
} public override ushort ReadUInt16()
{
if (UInt16List.Count() == )
{
return ;
}
return UInt16List[UInt16ListPt++];
} public override uint ReadUInt32()
{
if (UInt32List.Count() == )
{
return ;
}
return UInt32List[UInt32ListPt++];
} public override Vector2d ReadVector2d()
{
if (Vector2dList.Count() == )
{
return new Vector2d();
}
return Vector2dList[Vector2dListPt++];
} public override Vector3d ReadVector3d()
{
if (Vector3dList.Count() == )
{
return new Vector3d();
}
return Vector3dList[Vector3dListPt++];
} public override void ResetFilerStatus()
{
AddressList.Clear();
AddressListPt = ;
BinaryChunkList.Clear();
BinaryChunkListPt = ;
BooleanList.Clear();
BooleanListPt = ;
ByteList.Clear();
ByteListPt = ;
BytesList.Clear();
BytesListPt = ;
DoubleList.Clear();
DoubleListPt = ;
HandleList.Clear();
HandleListPt = ;
HardOwnershipIdList.Clear();
HardOwnershipIdListPt = ;
HardPointerIdList.Clear();
HardPointerIdListPt = ;
Int16List.Clear();
Int16ListPt = ;
Int32List.Clear();
Int32ListPt = ;
Int64List.Clear();
Int64ListPt = ;
Point2dList.Clear();
Point2dListPt = ;
Point3dList.Clear();
Point3dListPt = ;
Scale3dList.Clear();
Scale3dListPt = ;
SoftOwnershipIdList.Clear();
SoftOwnershipIdListPt = ;
SoftPointerIdList.Clear();
SoftPointerIdListPt = ;
StringList.Clear();
StringListPt = ;
UInt16List.Clear();
UInt16ListPt = ;
UInt32List.Clear();
UInt32ListPt = ;
UInt64List.Clear();
UInt64ListPt = ;
Vector2dList.Clear();
Vector2dListPt = ;
Vector3dList.Clear();
Vector3dListPt = ; m_FilerType = FilerType.CopyFiler;
} public override string ToString()
{
int ptCount =
AddressListPt +
BinaryChunkListPt +
BooleanListPt +
ByteListPt +
BytesListPt +
DoubleListPt +
HandleListPt +
HardOwnershipIdListPt +
HardPointerIdListPt +
Int16ListPt +
Int32ListPt +
Int64ListPt +
Point2dListPt +
Point3dListPt +
Scale3dListPt +
SoftOwnershipIdListPt +
SoftPointerIdListPt +
StringListPt +
UInt16ListPt +
UInt32ListPt +
UInt64ListPt +
Vector2dListPt +
Vector3dListPt;
int ltCount =
AddressList.Count() +
BinaryChunkList.Count() +
BooleanList.Count() +
ByteList.Count() +
BytesList.Count() +
DoubleList.Count() +
HandleList.Count() +
HardOwnershipIdList.Count() +
HardPointerIdList.Count() +
Int16List.Count() +
Int32List.Count() +
Int64List.Count() +
Point2dList.Count() +
Point3dList.Count() +
Scale3dList.Count() +
SoftOwnershipIdList.Count() +
SoftPointerIdList.Count() +
StringList.Count() +
UInt16List.Count() +
UInt32List.Count() +
UInt64List.Count() +
Vector2dList.Count() +
Vector3dList.Count(); return
"\n" + ptCount.ToString() + " DataIn" +
"\n" + ltCount.ToString() + " DataOut";
} public override void WriteAddress(IntPtr value)
{
AddressList.Add(value);
} public override void WriteBinaryChunk(byte[] chunk)
{
BinaryChunkList.Add(chunk);
} public override void WriteBoolean(bool value)
{
BooleanList.Add(value);
} public override void WriteByte(byte value)
{
ByteList.Add(value);
} public override void WriteBytes(byte[] value)
{
BytesList.Add(value);
} public override void WriteDouble(double value)
{
DoubleList.Add(value);
} public override void WriteHandle(Handle handle)
{
HandleList.Add(handle);
} public override void WriteHardOwnershipId(ObjectId value)
{
HardOwnershipIdList.Add(value);
} public override void WriteHardPointerId(ObjectId value)
{
HardPointerIdList.Add(value);
} public override void WriteInt16(short value)
{
Int16List.Add(value);
} public override void WriteInt32(int value)
{
Int32List.Add(value);
} public override void WritePoint2d(Point2d value)
{
Point2dList.Add(value);
} public override void WritePoint3d(Point3d value)
{
Point3dList.Add(value);
} public override void WriteScale3d(Scale3d value)
{
Scale3dList.Add(value);
} public override void WriteSoftOwnershipId(ObjectId value)
{
SoftOwnershipIdList.Add(value);
} public override void WriteSoftPointerId(ObjectId value)
{
SoftPointerIdList.Add(value);
} public override void WriteString(string value)
{
StringList.Add(value);
} public override void WriteUInt16(ushort value)
{
UInt16List.Add(value);
} public override void WriteUInt32(uint value)
{
UInt32List.Add(value);
} public override void WriteVector2d(Vector2d value)
{
Vector2dList.Add(value);
} public override void WriteVector3d(Vector3d value)
{
Vector3dList.Add(value);
} public override ErrorStatus FilerStatus
{
get
{
return m_FilerStatus;
}
set
{
m_FilerStatus = value;
}
} public override FilerType FilerType
{
get
{
return this.m_FilerType;
}
} #if !AC2008
public override long ReadInt64()
{
if (Int64List.Count() == )
{
return ;
}
return Int64List[Int64ListPt++];
} public override ulong ReadUInt64()
{
if (UInt64List.Count() == )
{
return ;
}
return UInt64List[UInt64ListPt++];
} public override void WriteInt64(long value)
{
Int64List.Add(value);
} public override void WriteUInt64(ulong value)
{
UInt64List.Add(value);
}
#endif //https://www.eabim.net//forum.php/?mod=viewthread&tid=169503&extra=page%3D1&page=1&
public override void Seek(
#if AC2008
int
#else
long
#endif
offset, int method)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(MethodInfo.GetCurrentMethod().Name + " = " + " \n ");
} public override
#if AC2008
int
#else
long
#endif
Position
{
get
{
return m_Position;
}
}
}

cad.net 块裁剪边界反向修剪的更多相关文章

  1. CAD中如何裁剪需要的区域

    M1: 先转换为块的方式进行裁剪 大范围框选复制出来>>B命令生成块>>XC命令>>选择刚才生成的块>>空格>>新边界>>框选新 ...

  2. CAD插入块后坐标不匹配

    有两张图,将一张图复制(CTRL+V),再另一张图中粘贴到原坐标(pasteorig),两张图可以很好匹配,但将一张图以外部参照的方式插入另一张图却发现图形无法匹配.因为没有看到图纸,所以我也没法准确 ...

  3. 使用FME将CAD中块参照数据转换为shp数据

    暴露出需要导出的字段值,首先在数据查看器中看看CAD中各个图层分别有哪些隐含的字段. CAD快参照中含有多个部分,需要将点按照原始编码聚合成一个点. 属性字段创建,并按照属性字段一一对应CAD中的字段 ...

  4. CAD绘图大师都在用的46组快捷键,高效绘图必备

    学习CAD 是一个需要慢慢积累的过程,千万不要遇到一点小困难就退缩,有困难我们就一起克服它!今天小编也是来帮助大家克服困难的!很多小伙伴学习CAD已经有一段时间了,但是发现自己的绘图效率还是不高,没关 ...

  5. 去块率波 Deblocking filter

    基于块的视频编码的一个典型特点就是在图像中会出现偶发的可察觉的块结构,这是由于重构块的边缘像素与块内部像素相比恢复精度要低,块效应是目前压缩编码最明显的视觉失真之一.在H.264/ AVC视频编码标准 ...

  6. h.264 去块滤波

    块效应及其产生原因 我们在观看视频的时候,在运动剧烈的场景常能观察到图像出现小方块,小方块在边界处呈现不连续的效果(如下图),这种现象被称为块效应(blocking artifact). 首先我们需要 ...

  7. 企业架构研究总结(35)——TOGAF架构内容框架之构建块(Building Blocks)

    之前忙于搬家移居,无暇顾及博客,今天终于得闲继续我的“政治课”了,希望之后至少能够补完TOGAF方面的内容.从前面文章可以看出,笔者并无太多能力和机会对TOGAF进行理论和实际的联系,仅可对标准的文本 ...

  8. TOGAF架构内容框架之构建块(Building Blocks)

    TOGAF架构内容框架之构建块(Building Blocks) 之前忙于搬家移居,无暇顾及博客,今天终于得闲继续我的“政治课”了,希望之后至少能够补完TOGAF方面的内容.从前面文章可以看出,笔者并 ...

  9. 让上下两个DIV块之间有一定距离或没有距离

    1.若想上下DIV块之间距离,只需设定:在CSS里设置DIV标签各属性参数为0div{margin:0;border:0;padding:0;}这里就设置了DIV标签CSS属性相当于初始化了DIV标签 ...

随机推荐

  1. asp.net MVC中使用EasyUI Treegrid 树形网格

    引入CSS和JS <link href="~/Content/plugins/jquery-easyui-1.7.0/themes/default/easyui.css" r ...

  2. Java中的集合类(List,Set.Map)

    1.List 1.1 Arraylist 与 LinkedList 区别 是否保证线程安全: ArrayList 和 LinkedList 都是不同步的,也就是不保证线程安全: 底层数据结构: Arr ...

  3. 把JSON数据格式转换为Python的类对象

    JOSN字符串转换为自定义类实例对象 有时候我们有这种需求就是把一个JSON字符串转换为一个具体的Python类的实例,比如你接收到这样一个JSON字符串如下: {"Name": ...

  4. Angular4 innerHtml呈现富文本内容样式

    import { Pipe, PipeTransform } from "@angular/core"; import { DomSanitizer } from '@angula ...

  5. SQLMAP源码阅读(一)

  6. OGG 源端与目标端 约束不一致

    需求: 请在生产库执行下面的脚本 --删除主键并新增复合主键              alter table XXXXX  drop constraint PK_USERCHNL cascade; ...

  7. win10自带截屏操作

    1.win+shift+S,自由截屏 2.win+W,截屏后编辑 3.alt+PrtSc,截取当前活动界面,鼠标在微信就是微信,在浏览器就是浏览器.在桌面就是所有界面. 4.PrtScn,截取所有屏幕 ...

  8. Python3和HTMLTestRunner生成html测试报告

    1.测试环境: Python3.5+unittest+HTMLTestRunner 2.下载HTMLTestRunner.py文件 下载地址 http://tungwaiyip.info/softwa ...

  9. 用java多线程模拟数据库连接池

    模拟一个ConnectionDriver,用于创建Connection package tread.demo.threadpool; import java.lang.reflect.Invocati ...

  10. wordcloud词云模块

    wordcloud词云模块 下载 pip install wordcloud 使用 import wordcloud##调用整个模块 form wordcloud import WordCloud## ...