生成截面几何问题
大家好,这是我的第一篇文章,所以你好,并提前感谢您的任何帮助!
我只是想知道是否有人能够成功重现生成多个对象的剖面视图?我希望实现“生成部分块”命令的无对话框版本。
在C#中,我试图使用“GenerateSectionGeometry”方法,但运气不好......任何人都可以帮忙吗?
谢谢,
詹姆斯
**** Hidden Message ***** 嗨,詹姆斯,欢迎加入!
GenerateSectionGeometry似乎是一个COM方法,所以我假设您已经加载了相关的设置和库。
您有任何代码要分享以开始使用吗?
另一个选择是HLR(隐藏线删除)引擎,但我不确定是否有. net包装器(?)。这是一个非常强大的工具,可以创建您想要的任何视图/s。 感谢Mick的回复,
请查看下面我现有的方法(请忽略顶部的零碎部分创建,我已经包括它只是为了给出完整的图片)。
我的问题是GenerateSectionView方法似乎一次只能在单个实体上运行,它从未使用整个对象选择ie运行。(不锈钢。SetGenerationOptions(section type。Section2d,SectionGeneration。source all objects | section generation。DestinationNewBlock);
非常感谢任何帮助...也许是时候深入了解ObjectARX了?再次感谢詹姆斯代码0]
public void CreateView()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Point3dCollection pts = new Point3dCollection();
// Get Corner 1
PromptPointResult ppr1 = ed.GetPoint("\nPick Top Left Corner: ");
if (ppr1.Status != PromptStatus.OK)
return;
// Get Corner 2
PromptCornerOptions pco2 = new PromptCornerOptions("\nPick Bottom Right Corner: ", ppr1.Value);
PromptPointResult ppr2 = ed.GetCorner(pco2);
if (ppr2.Status != PromptStatus.OK)
return;
// Get Left, Right and Middle Points
double wHeight = ppr1.Value.Y - ppr2.Value.Y;
double midPoint = ppr2.Value.Y + (wHeight / 2);
Point3d lPt = new Point3d(ppr1.Value.X, midPoint, 80000);
Point3d rPt = new Point3d(ppr2.Value.X, midPoint, 80000);
pts.Add(lPt);
pts.Add(rPt);
// Start Transaction
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt, OpenMode.ForWrite);
// Create Section
Section sec = new Section(pts, Vector3d.YAxis);
sec.State = SectionState.Plane;
// Add section to the drawing
ObjectId secId = ms.AppendEntity(sec);
tr.AddNewlyCreatedDBObject(sec, true);
// Set up some of its direct properties and settings
sec.SetHeight(SectionHeight.HeightAboveSectionLine, wHeight / 2);
sec.SetHeight(SectionHeight.HeightBelowSectionLine, wHeight / 2);
SectionSettings ss = (SectionSettings)tr.GetObject(sec.Settings, OpenMode.ForWrite);
ss.CurrentSectionType = SectionType.Section2d;
ss.SetGenerationOptions(SectionType.Section2d, SectionGeneration.SourceAllObjects | SectionGeneration.DestinationNewBlock);
ss.SetVisibility(SectionType.Section2d, SectionGeometry.IntersectionFill, false);
ss.SetVisibility(SectionType.Section2d, SectionGeometry.IntersectionFill, false);
ss.SetVisibility(SectionType.Section2d, SectionGeometry.CurveTangencyLines, false);
ss.SetVisibility(SectionType.Section2d, SectionGeometry.BackgroundGeometry, true);
ss.SetHiddenLine(SectionType.Section2d, SectionGeometry.BackgroundGeometry, false);
Autodesk.AutoCAD.Colors.Color c = new Autodesk.AutoCAD.Colors.Color();
c = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
ss.SetColor(SectionType.Section2d, SectionGeometry.BackgroundGeometry, c);
ss.SetLayer(SectionType.Section2d, SectionGeometry.BackgroundGeometry, "*_2D");
ss.SetLinetype(SectionType.Section2d, SectionGeometry.BackgroundGeometry, "ByLayer");
ss.SetLineWeight(SectionType.Section2d, SectionGeometry.BackgroundGeometry, LineWeight.ByLayer);
tr.Commit();
ed.WriteMessage("\n" + "Section created successfully");
}
catch (System.Exception ex)
{
ed.WriteMessage("\nException: " + ex.Message);
}
}
}
双wHeight=ppr1.Value.Y-ppr2.Value.Y;
如果y1=10和y2=-10 wHeight=20
似乎不需要角,只需选择该部分的2个点
页:
[1]