是否有View.GetOutline()的替代方法,可以提供更好的轮廓? [英] Is there an alternative to View.GetOutline() which gives a better outline?

查看:315
本文介绍了是否有View.GetOutline()的替代方法,可以提供更好的轮廓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

轮廓与可见的图形不太对应-它返回的数量比SolidWorks GUI显示的选择轮廓要多.

Outline returned by View.GetOutline() method does not quite correspond to the visible drawing - it returns a bit more than the selection outline shown by SolidWorks GUI.

下面的屏幕截图显示了选择轮廓(浅蓝色虚线矩形)和View.GetOutline()(红线)返回的轮廓的对角线:

The screenshot below shows the selection outline (light blue dotted rectangle) and diagonal of the outline returned by View.GetOutline() (red line):

有没有办法获得与实际可见的图形相对应的边界框?

注意:,该问题的原始标题是是否有View.GetOutline()的替代品,其中不包含临时轴?",但是我发现 实际上不包括临时轴.问题出在 View.Position 属性中,该属性定义了包括临时轴的中心边界框.
Artem的答案非常有用,因此我决定更改问题以使其与答案相对应,并发布

Note: Original title of this question was "Is there an alternative to View.GetOutline() which does NOT include Temporary Axes?", however I discovered that View.GetOutline() actually does not include Temporary Axes. The problem was in the View.Position property which defines center bounding box that includes Temporary Axes.
Artem's answer was quite useful so I decided to change the question to correspond to the answer and post a new question for the actual problem.

推荐答案

您可以通过IPartDoc :: GetBox/IAssemblyDoc :: GetBox API从基础模型中获取边界框,并通过IView :: ModelToViewTransform将其转换为视图空间,如下所示:在此示例中显示.

You can get the bounding box from underlying model via IPartDoc::GetBox/IAssemblyDoc::GetBox API and transform this to a view space via IView::ModelToViewTransform as shown in this example.

如果您不想绘制对角线,则只需要DrawBBoxDiagonal函数的以下代码部分. vStartPt和vEndPt的值是边界框的端点.

You will only need the following portion of code form the DrawBBoxDiagonal function if you do not want to draw the diagonal. The values of vStartPt and vEndPt are the end points of bounding box.

Dim vBox As Variant
Dim swViewTransform As SldWorks.MathTransform

Dim swMathPt As SldWorks.MathPoint
Dim vStartPt As Variant
Dim vEndPt As Variant

vBox = GetViewRefModelBBox(view)
Set swViewTransform = GetViewToSheetTransform(draw, view)

Dim swMathUtils As SldWorks.MathUtility
Set swMathUtils = swApp.GetMathUtility

Dim dPt(2) As Double
dPt(0) = vBox(0): dPt(1) = vBox(1): dPt(2) = vBox(2)

Set swMathPt = swMathUtils.CreatePoint(dPt)
Set swMathPt = swMathPt.MultiplyTransform(swViewTransform)
vStartPt = swMathPt.ArrayData

dPt(0) = vBox(3): dPt(1) = vBox(4): dPt(2) = vBox(5)

Set swMathPt = swMathUtils.CreatePoint(dPt)
Set swMathPt = swMathPt.MultiplyTransform(swViewTransform)
vEndPt = swMathPt.ArrayData

我还建议通过IBody2 :: GetExtremePoint获得精确的边界框,如

I would also recommend to get precise bounding box via IBody2::GetExtremePoint as shown here

这篇关于是否有View.GetOutline()的替代方法,可以提供更好的轮廓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆