I used it The select method wants to obtain objects in CAD drawings. It can meet the expected requirements under the appropriate size of the spatial view. However, when the view is zoomed (zoom - > A) to all, it obtains additional data. How can I solve this problem? thank you !
我使用了 .select 方法, 想获取CAD图形中的对象, 在空间视图合适的尺寸下, 它能完成预期要求, 但是, 当视图被缩放(zoom -> a)至全部时, 它获取多余的其他数据。
我该如何解决这个问题? 谢谢!
已解决! 转到解答。
ZOOM ALL zooms to the extents of the entire drawing plus some. From help:
All
Zooms to display all visible objects and visual aids.
Adjusts the magnification of the drawing area to accommodate the extents of all visible objects in the drawing, or visual aids such as the grid limits (the LIMITS command), whichever is larger.
If you want to zoom to the area for which you have the exact coordinates, use the zoom window command and specify the coordinates of the window.
Thank you for your reply!
The expected effect can be achieved by zooming the view
Another: I want to know how to get the zoom factor of the current view (for example, after zooming in the view with the mouse wheel)
感谢的你的回复!
通过缩放视图可以达到预计效果.
另: 我想知道如何获取当前视图的缩放因子(比如: 使用鼠标滚轮对视图进行放大操作后)
Here's a function I wrote to get the vp scale.
Public Function GetVPScale()
'returns the current viewport scale
'error checking: i.e., is PViewport active?
If ThisDrawing.ActiveSpace = acPaperSpace And ThisDrawing.MSpace = True Then
'Two ways to find viewport scale:
'First gets a ratio of the paperspace viewport's height
'to the height of the modelspace view
' Dim curPViewport As AcadPViewport
' Dim h1 As Double, h2 As Double
' Dim vpScale As Variant 'debugger
' Set curPViewport = ThisDrawing.ActivePViewport
'get height of viewport in ps units
' h1 = curPViewport.Height
'get height of viewport in ms units
' h2 = ThisDrawing.GetVariable("viewsize")
'MsgBox vpScale 'debugger
' GetVPScale = h2 / h1
'The second gets the z vector of the paperspace view. The Z coordinate is scaled
'but never translated. Therefore, it can be used to find the scale factor between
'the Paperspace Display Coordinate System (PSDS)and the DCS of the current viewport.
Dim TransPoint As Variant, NewPoint As Variant
Dim pt(0 To 2) As Double
pt(0) = 0#
pt(1) = 0#
pt(2) = 1#
TransPoint = pt
NewPoint = ThisDrawing.Utility.TranslateCoordinates(TransPoint, acPaperSpaceDCS, acDisplayDCS, False)
GetVPScale = NewPoint(2) 'return z value of array
End If
End Function
Thank you for your reply. I used the code example you provided, but it doesn't seem to work in model space
Another: I found that my purpose can be achieved in the Properties tab (which may need calculation). I can't get the parameters now. How can I get the parameters in the Properties tab?
Attached drawing < yellow box area >
谢谢你的回复。我使用了您提供的代码示例,但它似乎无法在模型空间中使用.
另一个:我发现我的目的可以在特性选项卡中实现(可能需要计算)。我现在无法获取其中的参数, 如何获取特性选项卡中的参数?
附图<黄框区域>
The code I gave you gives you the scale of a paperspace viewport. The yellow box you show is the extents of the current view. You asked for the "zoom factor". Which do you want?
You could use
ThisDrawing.GetVariable("viewctr")
ThisDrawing.GetVariable("viewsize")
But veiwsize only give the height. I can't find anything in vba that returns the current view width or coordinates. You can get the current view using the VIEW command. You could also save it as a named view. But the vba api doesn't have a CurrentView property.
In .NET, you can use the Editor.GetCurrentView Method.