CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

TranslateIDs Property (ActiveX)

2023-1-3 02:47| 发布者: admin| 查看: 173| 评论: 0|来自: AutoCAD

摘要: 指定在深度克隆或 wblockClone 操作期间任何包含的对象 ID 的转换。

指定在深度克隆或 wblockClone 操作期间任何包含的对象 ID 的转换。

支持的平台:仅窗口

签名

工 务 局:

object.TranslateIDs
对象

类型:X环保

此属性适用的对象。

属性值

只读:

类型:布尔

  • True:在深度克隆和 wblockClone 操作期间转换包含的 ID。
  • False:不要在深度克隆和 wblockClone 操作期间转换包含的 ID。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_TranslateIDs()
    ' This example creates a new XRecord if one doesn't exist,
    ' and toggles the setting for TranslateIDs
    
    Dim TrackingDictionary As AcadDictionary, TrackingXRecord As AcadXRecord
    Dim XRecordDataType As Variant, XRecordData As Variant
    Dim ArraySize As Long, iCount As Long
    Dim DataType As Integer, Data As String, msg As String
    
    ' Unique identifiers to distinguish our XRecordData from other XRecordData
    Const TYPE_STRING = 1
    Const TAG_DICTIONARY_NAME = "ObjectTrackerDictionary"
    Const TAG_XRECORD_NAME = "ObjectTrackerXRecord"

    ' Connect to the dictionary we store the XRecord in
    On Error GoTo CREATE
    Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
    Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
    On Error GoTo 0
    
    ' Get current XRecordData
    TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
    
    ' If we don't have an array already then create one
    If VarType(XRecordDataType) And vbArray = vbArray Then
        ArraySize = UBound(XRecordDataType) + 1       ' Get the size of the data elements returned
        ArraySize = ArraySize + 1                        ' Increase to hold new data
    
        ReDim Preserve XRecordDataType(0 To ArraySize)
        ReDim Preserve XRecordData(0 To ArraySize)
    Else
        ArraySize = 0
        ReDim XRecordDataType(0 To ArraySize) As Integer
        ReDim XRecordData(0 To ArraySize) As Variant
    End If
    
    ' Find the current value of TranslateIDs
    Dim currXlate As Boolean
    currXlate = TrackingXRecord.TranslateIDs
    MsgBox "The current setting of the TranslateIDs is " & currXlate
    
    ' Toggle the setting
    TrackingXRecord.TranslateIDs = Not currXlate
    MsgBox "The new setting for the TranslateIDs is " & TrackingXRecord.TranslateIDs
    
    ' Reset the value
    TrackingXRecord.TranslateIDs = currXlate
    MsgBox "TranslateIDs has been reset to " & TrackingXRecord.TranslateIDs
    
    Exit Sub

CREATE:
    ' Create the entities that hold our XRecordData
    If TrackingDictionary Is Nothing Then  ' Make sure we have our tracking object
        Set TrackingDictionary = ThisDrawing.Dictionaries.Add(TAG_DICTIONARY_NAME)
        Set TrackingXRecord = TrackingDictionary.AddXRecord(TAG_XRECORD_NAME)
    End If
    
    Resume
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TranslateIDs()
    ;; This example creates a new XRecord if one doesn't exist,
    ;; and toggles the setting for TranslateIDs
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Unique identifiers to distinguish our XRecordData from other XRecordData
    (setq TYPE_STRING 1
          TAG_DICTIONARY_NAME "ObjectTrackerDictionary"
          TAG_XRECORD_NAME "ObjectTrackerXRecord")

    ;; Connect to the dictionary we store the XRecord in
    (setq dictionaries (vla-get-Dictionaries doc))
    (setq TrackingDictionary (vl-catch-all-apply 'vla-Item (list dictionaries TAG_DICTIONARY_NAME)))

    ;; (= (vl-catch-all-error-message TrackingDictionary) "Automation Error. Key not found")
  
    (if (= (type TrackingDictionary) 'VLA-OBJECT)
        (setq TrackingXRecord (vla-GetObject TrackingDictionary TAG_XRECORD_NAME))
        (progn
            ;; Create the objects that hold this XRecordData
            (setq TrackingDictionary (vla-Add dictionaries TAG_DICTIONARY_NAME))
            (setq TrackingXRecord  (vla-AddXRecord TrackingDictionary TAG_XRECORD_NAME))
	       )
    )

    ;; Get current XRecordData
    (vla-GetXRecordData TrackingXRecord 'temp-XRecordDataType 'temp-XRecordData)
    
    ;; If we don't have an array already then create one
    (setq ArraySize 0)
    (if (/= temp-XRecordDataType nil)
        (progn
	    (setq ArraySize (vlax-safearray-get-u-bound temp-XRecordDataType 1))
            (setq XRecordDataType (vlax-make-safearray vlax-vbInteger (cons 0 (1+ ArraySize))))
            (setq XRecordData (vlax-make-safearray vlax-vbVariant (cons 0 (1+ ArraySize))))

            (setq iCount 0)
            (while (>= ArraySize iCount)
                ;; Get information for this element
                (setq DataType (vlax-safearray-get-element temp-XRecordDataType iCount))
                (setq Data (vlax-variant-value (vlax-safearray-get-element temp-XRecordData iCount)))

                (vlax-safearray-put-element XRecordDataType iCount DataType)
                (vlax-safearray-put-element XRecordData iCount Data)
	      
                (setq iCount (1+ iCount))
            )
	       )
        (progn
            (setq XRecordDataType (vlax-make-safearray vlax-vbInteger '(0 . 0)))
            (setq XRecordData (vlax-make-safearray vlax-vbVariant '(0 . 0)))
	       )
    )
    
    ;; Find the current value of TranslateIDs
    (setq currXlate (vla-get-TranslateIDs TrackingXRecord))
    (alert (strcat "The current setting of the TranslateIDs is " (if (= currXlate :vlax-true) "True" "False")))
    
    ;; Toggle the setting
    (vla-put-TranslateIDs TrackingXRecord (if (= currXlate :vlax-true) :vlax-false :vlax-true))
    (alert (strcat "The new setting for the TranslateIDs is " (if (= (vla-get-TranslateIDs TrackingXRecord) :vlax-true) "True" "False")))
    
    ;; Reset the value
    (vla-put-TranslateIDs TrackingXRecord currXlate)
    (alert (strcat "TranslateIDs has been reset to " (if (= (vla-get-TranslateIDs TrackingXRecord) :vlax-true) "True" "False")))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:29

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部