马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 csharp 于 2014-4-20 16:18 编辑
- [LispFunction("GetSplitCurves")]
- public static ResultBuffer GetSplitCurves(ResultBuffer rb)
- {
- ResultBuffer ret = new ResultBuffer();
- Document document = Application.DocumentManager.MdiActiveDocument;
- Editor editor= document.Editor;
- Transaction transaction = document.TransactionManager.StartTransaction();
- Database db = document.Database;
- using (transaction )
-
- try
- {
- if (rb != null)
- {
- TypedValue[] rbArr = rb.AsArray();
- DoubleCollection doubleCollection = new DoubleCollection( );
- TypedValue entId = rbArr[0];
- ObjectId id = (ObjectId)entId.Value;
- Curve curve = (Curve )transaction.GetObject(id, OpenMode.ForWrite);
- if (curve.Closed ) doubleCollection.Add(curve.StartParam);
- foreach (TypedValue arg in rbArr)
- {
- switch (arg.TypeCode)
- {
- case 5001:
- double n = Convert.ToDouble(arg.Value);
- doubleCollection.Add(n);
- break;
- case 5003:
- //short ii = (short) arg.Value;
- double nn = Convert.ToDouble(arg.Value);
- doubleCollection.Add(nn);
- break;
- case 5004:
- int iii = (int) arg.Value;
- double nnn = iii;
- doubleCollection.Add(nnn);
- break;
- default :
- break;
- }
- }
- foreach (double i in doubleCollection)
- {
- editor.WriteMessage(i.ToString());
- }
- DBObjectCollection dbObjectCollection = curve.GetSplitCurves(doubleCollection );
- BlockTableRecord Spase = (BlockTableRecord)transaction.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
- foreach (DBObject cDbObject in dbObjectCollection )
- {
- Spase.AppendEntity((Entity)cDbObject);
- transaction .AddNewlyCreatedDBObject(cDbObject, true);
- }
- curve.Erase();
- // */
- }
- transaction.Commit();
- return null;
- }
- catch (Exception)
- {
- throw;
- }
- }
在Lisp下断开曲线很麻烦,XdRxAPI 中有个 xdrx_curve_getsplitcurves ,模仿在写了一个,因为初学 C# ,很不完善,只能用 Pamram 而且要自己先行由小到大排好序,另外对封闭曲线处理的不好,在起始点处会多断开一段
使用方法
(getsplitcurves curve pam1 pam2 pam3 ...) |