马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [LispFunction("Entity_Transform")]
- public void EntityTransform(ResultBuffer rb)
- {
- TypedValue[] values = rb.AsArray();
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Transaction tr = doc.TransactionManager.StartTransaction();
- if (rb != null)
- {
- if (values[0].TypeCode == (int) LispDataType.ObjectId | values[0].TypeCode == (int)LispDataType.SelectionSet)
- {
- Double[] data = new double[16];
- int j = 0;
- for (int i = 0; i < values.Count(); i++)
- {
- if (values.TypeCode == (int)LispDataType.Double)
- {
- data[j] = (double)values.Value;
- j++;
- }
- }
- Matrix3d matrix3D = new Matrix3d(data);
- using (tr)
- try
- {
- if (values[0].TypeCode == (int) LispDataType.ObjectId)
- {
- ObjectId id = (ObjectId) values[0].Value;
- Entity ent = (Entity )tr.GetObject(id, OpenMode.ForWrite);
- ent.TransformBy(matrix3D);
- }
- else
- {
- SelectionSet sset = (SelectionSet) values[0].Value;
- foreach (ObjectId id in sset.GetObjectIds() )
- {
- Entity ent = (Entity) tr.GetObject(id, OpenMode.ForWrite);
- ent.TransformBy(matrix3D);
- }
- }
- tr.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|