SnapBasePoint 属性 (ActiveX) 
指定视口的对齐基点。 支持的平台:仅限 Windows 属性值只读:不 类型:变体(双精度的双元素数组) 表示视口的捕捉基点的 2D WCS 坐标。 言论不能更改活动图纸空间视口的对齐基点。 在执行对 or 方法的调用之前,对此属性的更改不会反映在显示中。UpdateRegen 注意:此属性的值存储在 SNAPBASE 系统变量中。 
例子VBA: Sub Example_SnapBasePoint()
    ' This example changes the snap base point for a
    ' model space and paper space viewport.
    
    ' Create a new model space viewport
    Dim viewportObj As AcadViewport
    Set viewportObj = ThisDrawing.Viewports.Add("NewViewport")
    
    ' Find the current snap base point
    Dim currSnapPnt As Variant
    currSnapPnt = viewportObj.SnapBasePoint
    MsgBox "The current model space snap base point is " & viewportObj.SnapBasePoint(0) & ", " & viewportObj.SnapBasePoint(1), , "SnapBasePoint Example"
    
    ' Change the snap base point
    Dim newSnapPnt(0 To 1) As Double
    newSnapPnt(0) = 5#: newSnapPnt(1) = 5#
    viewportObj.SnapBasePoint = newSnapPnt
    MsgBox "The new model space snap base point is " & viewportObj.SnapBasePoint(0) & ", " & viewportObj.SnapBasePoint(1), , "SnapBasePoint Example"
    
    ' Create a new paper space viewport
    Dim pviewportObj As AcadPViewport
    Dim center(0 To 2) As Double
    Dim width As Double
    Dim height As Double
    
    center(0) = 3: center(1) = 3: center(2) = 0
    width = 40
    height = 40
    ThisDrawing.ActiveSpace = acPaperSpace
    Set pviewportObj = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
    
    ' Find the current snap base point
    currSnapPnt = pviewportObj.SnapBasePoint
    MsgBox "The current paper space snap base point is " & pviewportObj.SnapBasePoint(0) & ", " & pviewportObj.SnapBasePoint(1), , "SnapBasePoint Example"
    
    ' Change the snap base point
    newSnapPnt(0) = 2#: newSnapPnt(1) = 2#
    pviewportObj.SnapBasePoint = newSnapPnt
    MsgBox "The new paper space snap base point is " & pviewportObj.SnapBasePoint(0) & ", " & pviewportObj.SnapBasePoint(1), , "SnapBasePoint Example"
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_SnapBasePoint()
    ;; This example changes the snap base point for a
    ;; model space and paper space viewport.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    ;; Create a new model space viewport
    (setq viewportObj (vla-Add (vla-get-Viewports doc) "NewViewport"))
    
    ;; Find the current snap base point
    (setq currSnapPnt (vlax-variant-value (vla-get-SnapBasePoint viewportObj)))
    (alert (strcat "The current model space snap base point is " (rtos (vlax-safearray-get-element currSnapPnt 0) 2) ", "
                                                                 (rtos (vlax-safearray-get-element currSnapPnt 1) 2)))
    ;; Change the snap base point
    (setq newSnapPnt (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill newSnapPnt '(5 5)) 
    (vla-put-SnapBasePoint viewportObj newSnapPnt)
    (alert (strcat "The new model space snap base point is " (rtos (vlax-safearray-get-element newSnapPnt 0) 2) ", "
                                                             (rtos (vlax-safearray-get-element newSnapPnt 1) 2)))
    ;; Create a new paper space viewport
    (setq center (vlax-3d-point 3 3 0)
          width 40
	         height 40)
    (vla-put-ActiveSpace doc acPaperSpace)
    (setq paperSpace (vla-get-PaperSpace doc))
    (setq pviewportObj (vla-AddPViewport paperSpace center width height))
    
    ;; Find the current snap base point
    (setq currSnapPnt (vlax-variant-value (vla-get-SnapBasePoint pviewportObj)))
    (alert (strcat "The current paper space snap base point is " (rtos (vlax-safearray-get-element currSnapPnt 0) 2) ", "
                                                                 (rtos (vlax-safearray-get-element currSnapPnt 1) 2)))
    
    ;; Change the snap base point
    (setq newSnapPnt (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill newSnapPnt '(2 2)) 
    (vla-put-SnapBasePoint pviewportObj newSnapPnt)
    (alert (strcat "The new paper space snap base point is " (rtos (vlax-safearray-get-element newSnapPnt 0) 2) ", "
                                                             (rtos (vlax-safearray-get-element newSnapPnt 1) 2)))
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 13:37
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.