ディクショナリ内の項目を、与えられた項目に置き換えます。
サポートされているプラットフォーム: Windows のみ
VBA:
object.Replace Name, NewObject
タイプ: Dictionary
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ
タイプ: 文字列
置き換えられるオブジェクトの名前(キーワード)。
アクセス: 入力のみ
タイプ: Object
新しいオブジェクト。
戻り値はありません。
たとえば、次のようなディクショナリで、"FirstKeyword" という名前のオブジェクトを置き換えます。
新しいオブジェクト「NewObject」によって、次のようなディクショナリになります。
VBA:
Sub Example_Replace() ' This example creates a dictionary and adds ' a custom object to that dictionary. It then ' replaces the object in the dictionary. Dim dictObj As AcadDictionary Set dictObj = ThisDrawing.Dictionaries.Add("TEST_DICTIONARY") ' Load the ObjectARX application that defines the custom object. ' Note: The application listed here does not exist and ' will cause an error when run. Change the application name ' to the path and name of your ObjectARX application. ThisDrawing.Application.LoadArx "MyARXApp.dll" ' Create the custom object in the dictionary Dim keyName As String Dim className As String Dim customObj As AcadObject keyName = "OBJ1" className = "CAsdkDictObject" Set customObj = dictObj.AddObject(keyName, className) ' Replace the object from the dictionary with a different object Dim newCustomObject As AcadObject dictObj.Replace keyName, newCustomObject End Sub
Visual LISP:
(vl-load-com) (defun c:Example_Replace() ;; This example creates a dictionary and adds ;; a custom object to that dictionary. It then ;; replaces the object in the dictionary. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq dictionaries (vla-get-Dictionaries doc)) (setq dictObj (vla-Add dictionaries "TEST_DICTIONARY")) ;; Load the ObjectARX application that defines the custom object. ;; Note: The application listed here does not exist and ;; will cause an error when run. Change the application name ;; to the path and name of your ObjectARX application. (vla-LoadArx acadObj "MyARXApp.dll") ;; Create the custom object in the dictionary (setq keyName "OBJ1") (setq className "CAsdkDictObject") (setq customObj (vla-AddObject dictObj keyName className)) ;; Replace the object from the dictionary with a different object (setq newCustomObject (vlax-make-variant)) (vlax-variant-type newCustomObject vlax-vbObject) (vla-Replace dictObj keyName newCustomObject) )