感谢MickD.<br>So..将文本创建为一个实体(即:非文本/多行文本),我非常依赖此处(以及OP中)描述的SEANT解决方案:https://www.theswamp.org/index.php?topic=31435.0它工作得很完美,(我可能在其他地方找到了该代码的更新版本……但前提是一样的。)。因此,我有文本…和管道..,这使我找到了接受块引用实体的代码,该实体是转换为区域的文本),我想:
1.挤出文本区域
2.创建圆柱体,用于从文本区域中减去,以获得“环绕”效果
3.正确定位圆柱体和文本区域(此处需要帮助!)
以下是代码:
- // FYI - the following are as held as member variables
- // List> pipeProperties;
- // private Point3d position;
- // private Point3d centerOfPipe;
- // private double extrudeHeight;
- // private double outsideDiameter;
- // private double wallThickness;
- // private double pipeLength;
- // private Vector3d pipeVector;
- private void CreateEnt(Entity ent)
- {
- // Scale the text height...
- Extents3d geometricExtents = ent.GeometricExtents;
- Point3d point3d = new Point3d();
- double mHeight = this.m_height;
- Vector3d vectorTo = point3d.GetVectorTo(geometricExtents.MaxPoint);
- double y = mHeight / vectorTo.Y;
- ent.TransformBy(Matrix3d.Scaling(y, point3d));
- using (Transaction tr = this.m_db.TransactionManager.StartTransaction())
- {
- try
- {
- BlockTableRecord btr = tr.GetObject(this.m_db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
- ent.SetDatabaseDefaults();
- // Extrude this region just beyond the thickness of the pipe...
- var pSolid = new Solid3d { RecordHistory = true };
- pSolid.Extrude(ent as Region, extrudeHeight, 0.0);
- // Move this region to the center point of the pipe, and move it down so it is vertically center justified...
- var centerJustPoint = new Point3d(centerOfPipe.X, centerOfPipe.Y, centerOfPipe.Z - (extrudeHeight / 4.0));
- pSolid.TransformBy(Matrix3d.Displacement(centerJustPoint - Point3d.Origin));
- // Now the text region is by default oriented so that the text is laying down flat. Hard code transform to be "vertical" so the
- // text region is up.
- // ** how do I figure out the proper orientation of the text region to match the orientation of the pipe...??
- Matrix3d matrix = Matrix3d.Rotation(Math.PI / 2, Vector3d.XAxis, centerJustPoint);
- pSolid.TransformBy(matrix);
-
- // Add this solid to the model...
- btr.AppendEntity(pSolid);
- tr.AddNewlyCreatedDBObject(pSolid, true);
- // Create the cylinder that will be subtracted from the text regoin, and move it to the center point of the pipe..
- var cyl = new Solid3d { RecordHistory = true };
- var radius = (outsideDiameter / 2.0);
- cyl.CreateFrustum(pipeLength, radius, radius, radius);
- cyl.TransformBy(Matrix3d.Displacement(centerOfPipe - Point3d.Origin));
- // Now this cylinder and text region is simply using the default orientation. Manually hard code to orientate it, just like above,
- // so that it matches the text orientation..
- // ** obviouslly this is wrong and won't handle, for example, vertical pipes.. how do I align this and the text to the orientation
- // of the pipe.
-
- Matrix3d matrix2 = Matrix3d.Rotation(Math.PI / 2, Vector3d.YAxis, centerOfPipe);
- cyl.TransformBy(matrix2);
- // Lots of test code here to try to orientate / align the cylinder and text to the pipe... see previous post that describes the approaches
- // that I attempted, but couldn't figure out...
-
- btr.AppendEntity(cyl);
- tr.AddNewlyCreatedDBObject(cyl, true);
- // Subtract the cylinder from the text region..
- pSolid.BooleanOperation(BooleanOperationType.BoolSubtract, cyl);
- }
- catch
- {
- this.m_isValid = false;
- }
- finally
- {
- tr.Commit();
- }
- }
- }
现在,这段代码让我了解了我之前的屏幕截图。因此,如果管道是完全水平的……一切看起来都很好,它让我实现了您在最初答复中为我概述的策略。因此,我觉得繁重的工作已经完成。正是这个对齐问题阻碍了我。
我附上了一个显示管道的测试图纸,(这是一个Plant3D图纸……希望您能够打开它。) |