一天的学习成果
 - [LispFunction("GetStretchPoint")]//定义一个函数名称,Lispfuction
- public static ResultBuffer getStretchPoint (ResultBuffer rb)//要用返回值模式 ResultBuffer
- {
- ResultBuffer resultBuffer = new ResultBuffer();//初始化返回值链表
- Document document = Application.DocumentManager.MdiActiveDocument;//当前文档
- Transaction trtTransaction = document .TransactionManager.StartTransaction();//事务处理
- using (trtTransaction)
- {
- try
- {
- //参数不能为 nil
- if (rb != null)
- {
- TypedValue[] rbArr = rb.AsArray(); //Convoert to Array
- TypedValue entId = rbArr[0];//取出第一个参数
- //并且是 Entity 并且只有一个参数
- if (entId.TypeCode == (int)LispDataType.ObjectId && rbArr.Length == 1)
- {
- ObjectId objId = (ObjectId)entId.Value;//将第一个参数转换为Object
- Entity entity = (Entity) trtTransaction.GetObject(objId , OpenMode.ForRead, false);//转换为Entity
- Point3dCollection pnts = new Point3dCollection();//初始化一个保存StretchPoints 的集合
- entity.GetStretchPoints(pnts);//获取Entity的StretchPoints赋给 pnts
- //将 获取的 Pnts 中的值加入到返回值
- foreach (Point3d pnt in pnts)
- {
- resultBuffer.Add(new TypedValue((int)LispDataType.Point3d, pnt));
- };
- }
- }
- trtTransaction.Commit();//提交事务处理
- return resultBuffer;//返回值
- }
- //错误处理暂时还没有学到
- catch (Exception)
- {
-
- throw;
- }
- }
- }
|