CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

IsXRef Property (ActiveX)

2023-1-3 13:20| 发布者: admin| 查看: 504| 评论: 0|来自: AutoCAD

摘要: 确定给定块是否为外部参照块。

确定给定块是否为外部参照块。

支持的平台:仅窗口

签名

工 务 局:

object.IsXRef
对象

类型:

此属性适用的对象。

属性值

只读:是的

类型:布尔

  • True:该块是外部参照。
  • False:该块不是 XRef。

言论

该物业与该物业合作。如果两个属性都是,则块是一个简单的块。如果属性是,则块是外部引用。如果属性为 ,则块包含与布局关联的所有几何图形。IsXRefIsLayoutFalseIsXRefTrueIsLayoutTrue

例子

工 务 局:

Sub Example_IsXRef()
    ' This example cycles through each Block object in a drawing
    ' and determines the style of each Block by accessing the
    ' IsLayout and IsXRef properties.  A Block
    ' object is also added at runtime so the results are mixed and do not only
    ' come from the default Blocks.
    
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double, InsertPoint(0 To 2) As Double
    Dim radius As Double
    Dim newBlock As AcadBlock, insertedBlock As AcadBlockReference
    Dim tempBlock As AcadBlock
    Dim msg As String
    
    ' Define the Circle object that will be inserted into the block
    centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
    InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
    radius = 0.5
    
    ' Create a new block to hold the Circle object
    Set newBlock = ThisDrawing.Blocks.Add(centerPoint, "CBlock")
    
    ' Add the Circle object to the new block object
    Set circleObj = ThisDrawing.Blocks("CBlock").AddCircle(centerPoint, radius)
    
    ' Add the new block to model space
    Set insertedBlock = ThisDrawing.ModelSpace.InsertBlock(InsertPoint, "CBlock", 1, 1, 1, 0)
        
    ThisDrawing.Application.ZoomAll
    
    msg = vbCrLf & vbCrLf
    
    For Each tempBlock In ThisDrawing.Blocks
        If Not (tempBlock.IsLayout) And Not (tempBlock.IsXRef) Then
            ' Block is simple
            msg = msg & tempBlock.name & ": Simple"
        ElseIf tempBlock.IsXRef Then
            ' Block is an external reference
            msg = msg & tempBlock.name & ": External Reference"
            If tempBlock.IsLayout Then
                ' Block also contains layout geometry
                msg = msg & tempBlock.name & " and Contains Layout Geometry"
            End If
        ElseIf tempBlock.IsLayout Then
            ' Block contains layout geometry
            msg = msg & tempBlock.name & ": Contains Layout Geometry"
        End If
        
        msg = msg & vbCrLf      ' Move to next line
    Next
        
    ' Display Block information for this drawing
    MsgBox "Blocks in this drawing have the following styles: " & msg

End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_IsXref()
    ;; This example cycles through each Block object in a drawing
    ;; and determines whether style of each Block by accessing the
    ;; IsLayout and IsXRef properties.  A Block
    ;; object is also added at runtime so the results are mixed and do not only
    ;; come from the default Blocks.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the Circle object that will be inserted into the block
    (setq centerPoint (vlax-3d-point 0 0 0)
          insertPoint (vlax-3d-point 1 1 0)
          radius 0.5)
    
    ;; Create a new block to hold the Circle object
    (setq newBlock (vla-Add (vla-get-Blocks doc) centerPoint "CBlock"))
    
    ;; Add the Circle object to the new block object
    (setq circleObj (vla-AddCircle (vla-Item (vla-get-Blocks doc) "CBlock") centerPoint radius))
    
    ;; Add the new block to model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq insertedBlock (vla-InsertBlock modelSpace InsertPoint "CBlock" 1 1 1 0))
        
    (vla-ZoomAll acadObj)
    
    (setq msg "")
    
    (vlax-for tempBlock (vla-get-Blocks doc)
        (cond
            ((and (= (vla-get-IsLayout tempBlock) :vlax-false)
                  (= (vla-get-IsXRef tempBlock) :vlax-false))
                ;; Block is simple
                (setq msg (strcat msg (vla-get-Name tempBlock) ": Simple"))
            )
            ((= (vla-get-IsXRef tempBlock) :vlax-true)
                ;; Block is simple
                (setq msg (strcat msg (vla-get-Name tempBlock) ": External Reference"))
                (if (= (vla-get-IsLayout tempBlock) :vlax-true)
                    ;; Block also contains layout geometry
                    (setq msg (strcat msg (vla-get-Name tempBlock) " and Contains Layout Geometry"))
                )
            )
            ((= (vla-get-IsLayout tempBlock) :vlax-true)
                ;; Block is simple
                (setq msg (strcat msg (vla-get-Name tempBlock) ": Contains Layout Geometry"))
            )
        )
        (setq msg (strcat msg "\n"))
    )
        
    ;; Display Block information for this drawing
    (alert (strcat "Blocks in this drawing have the following styles: " msg))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 17:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部