SetCustomScale メソッド(ActiveX)

レイアウトまたは印刷設定のカスタム尺度を設定します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

object.SetCustomScale Numerator, Denominator
object

タイプ: LayoutPlotConfiguration

このメソッドが適用されるオブジェクト。

Numerator

アクセス: 入力のみ

タイプ: 倍精度浮動小数点数型

尺度の比率の分子を示す正の数。この値は尺度のインチ数またはミリメートル数を示します。

Denominator

アクセス: 入力のみ

タイプ: 倍精度浮動小数点数型

尺度の比率の分母を示す正の数。この値は尺度の作図単位の数を示します。

戻り値(RetVal)

戻り値はありません。

注意

Numerator パラメータの単位は PaperUnits プロパティで見つけることができます。

パラメータ Numerator および Denominator はゼロより大きくなければなりません。

このメソッドによる変更は、図面の再作図が終わるまで表示されません。Regen メソッドを使用して図面を再作図してください。

VBA:

Sub Example_SetCustomScale()
    ' This example will access the Layouts collection for the current drawing
    ' and list basic information about the custom scale for each Layout.
    ' It will then change the custom scale information for model space and re-display
    ' the scale information.

    Dim Layouts As AcadLayouts, Layout As ACADLayout
    Dim msg As String
    Dim Numerator As Double, Denominator As Double
    Dim Measurement As String
    
    ' Display current scale information
    GoSub DISPLAY_SCALE_INFO
    
    ' Modify scale
    Numerator = 1
    Denominator = 1
    
    ThisDrawing.Layouts("Model").SetCustomScale Numerator, Denominator
    ThisDrawing.Regen acAllViewports
            
    ' Display new scale information
    GoSub DISPLAY_SCALE_INFO
        
    Exit Sub
    
DISPLAY_SCALE_INFO:
    ' Get layouts collection from document object
    Set Layouts = ThisDrawing.Layouts
    
    msg = vbCrLf & vbCrLf   ' Start with a space
    
    ' Get the scale information of every layout in this drawing
    For Each Layout In Layouts
        msg = msg & Layout.name & vbCrLf
        
        ' Get scale information
        Layout.GetCustomScale Numerator, Denominator
        
        ' Identify whether inches or millimeters are being used.
        Measurement = IIf(Layout.PaperUnits = acInches, " inch(es)", " millimeter(s)")
        
        ' Format for display
        msg = msg & vbTab & "Contains " & Numerator & Measurement & vbCrLf
        msg = msg & vbTab & "Contains " & Denominator & " drawing units" & vbCrLf
        msg = msg & "_____________________" & vbCrLf
        
    Next
    
    ' Display custom scale information
    MsgBox "Custom scale information for the current drawing is: " & msg
    
    Return
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetCustomScale()
    ;; This example will access the Layouts collection for the current drawing
    ;; and list basic information about the custom scale for each Layout.
    ;; It will then change the custom scale information for model space and re-display
    ;; the scale information.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Display current scale information
    (setq Layouts (vla-get-Layouts doc))
    
    (setq msg "")
    
    ;; Get the scale information of every layout in this drawing
    (vlax-for Layout Layouts
        (setq msg (strcat msg (vla-get-Name Layout) "\n"))
        
        ;; Get scale information
        (vla-GetCustomScale Layout 'Numerator 'Denominator)
        
        ;; Are we using inches or millimeters
        (setq Measurement (if (= (vla-get-PaperUnits Layout) acInches) " inch(es)\n" " millimeter(s)\n"))
        
        ;; Format for display
        (setq msg (strcat msg "  Contains " (rtos Numerator 2) Measurement
                              "  Contains " (rtos Denominator 2) " drawing units\n"
                              "_____________________\n"))   
    )
    
    ;; Display custom scale information
    (alert (strcat "Custom scale information for the current drawing is: " msg))
  
    ;; Modify scale
    (setq Numerator 1
          Denominator 1)
    
    (vla-SetCustomScale (vla-Item (vla-get-Layouts doc) "Model") Numerator Denominator)
    (vla-Regen doc acAllViewports)
            
    ;; Display new scale information
    (setq Layouts (vla-get-Layouts doc))
    
    (setq msg "")
    
    ;; Get the scale information of every layout in this drawing
    (vlax-for Layout Layouts
        (setq msg (strcat msg (vla-get-Name Layout) "\n"))
        
        ;; Get scale information
        (vla-GetCustomScale Layout 'Numerator 'Denominator)
        
        ;; Are we using inches or millimeters
        (setq Measurement (if (= (vla-get-PaperUnits Layout) acInches) " inch(es)\n" " millimeter(s)\n"))
        
        ;; Format for display
        (setq msg (strcat msg "  Contains " (rtos Numerator 2) Measurement
                              "  Contains " (rtos Denominator 2) " drawing units\n"
                              "_____________________\n"))   
    )

    ;; Display custom scale information
    (alert (strcat "Custom scale information for the current drawing is: " msg))
)