欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CAD实体与AS元素之间的访问

程序员文章站 2022-03-14 15:55:20
...

// convert this id from “AdvanceSteel” id to “Acad” id
一:通过ID交换的实现:
1:AS---->>>CAD

// get the "representation" id - the id that AutoCAD understands as being the object drawn on the screen
    ASObjectId reprId = DatabaseManager.GetReprId(beam);
    ObjectId acadIdBeam = new ObjectId(reprId.AsOldId());

2:CAD---->>>AS


 ObjectId[] ids = acSSet.GetObjectIds();
 //Iterate through the selected objects, and check if we have a straight beam
 foreach (ObjectId id in ids)
    {
       //Get the beam filer object
       ASObjectId idDbObject = DatabaseManager.GetFilerObjectId(new ASObjectId(id.OldIdPtr), false);
       FilerObject obj = DatabaseManager.Open(idDbObject);
   }

二:cad----->>as转换
通过提取CAD实体的信息重新生成AS元素


polyline = acTrans.GetObject(acEnt.ObjectId, OpenMode.ForWrite) as Polyline;//cad实体polyline
index = 0;
CircularArc3d arc3D = polyline.GetArcSegmentAt(index);//获取多段线中的弧0,1,2,3...
Point3d point3D = polyline.GetPoint3dAt(index);//获取多段线的顶点坐标0,1,2,3...
double bulg = polyline.GetBulgeAt(index);//获取多段线中的曲度值0,1,2,3...
MessageBox.Show("\n 多段线半径:" + arc3D.Radius);
MessageBox.Show("\n 多段线拐点数目:" + polyline.NumberOfVertices);
MessageBox.Show("\n 多段线顶点坐标:" + point3D.X + " " + point3D.Y + " " + point3D.Z);
MessageBox.Show("\n 多段线曲度1:" + bulg);
MessageBox.Show("\n 多段线曲度2:" + polyline.GetBulgeAt(2));

相关标签: ID转换