Private Sub CommandButton1_Click()

Dim pEntity As AcadObject

Dim pBlock As AcadBlockReference

Dim pPolyline As AcadLWPolyline

Dim pSlct As AcadSelectionSet

'若 Entity 选择集存在,则删除选择集,删除后并添加

For i = 0 To ThisDrawing.SelectionSets.Count - 1

If ThisDrawing.SelectionSets.Item(i).Name = "Entity" Then

Set pSlct = ThisDrawing.SelectionSets.Item(i)

pSlct.Delete

End If

Next i

Set pSlct = ThisDrawing.SelectionSets.Add("Entity")

'隐藏窗体,并用 SelectOnScreen 方法选择

UserForm1.Hide

pSlct.SelectOnScreen

'定义要获取的数据的类型和数据载体

Dim pXDataType As Variant

Dim pXDatavlaue As Variant

'定义块的插入点,坐标存放数组

Dim pInsertPt As Variant

Dim pCoords As Variant

Dim sCoor As String

For Each pEntity In pSlct

'Debug.Print pEntity.ObjectName

If pEntity.ObjectName = "AcDbBlockReference" Then

Set pBlock = pEntity

pBlock.GetXData "SOUTH", pXDataType, pXDatavlaue

pInsertPt = pBlock.InsertionPoint

'Debug.Print pXDataType(0) & "," & pXDataType(1)

'Debug.Print pXDatavlaue(1) & "," & pInsertPt(0) & "," & pInsertPt(1) & "," & pBlock.Linetype & "," & pBlock.LinetypeScale & "," & pBlock.Lineweight & "," & pBlock.HasAttributes & "," & pBlock.XScaleFactor & "," & pBlock.YScaleFactor&; "," & pBlock.ZScaleFactor

'Debug.Print pBlock.Name & "," & pBlock.Layer

'Debug.Print pBlock.ObjectID & "," & pBlock.Handle & "," & pXDatavlaue(1) & "," & pInsertPt(0) & "," & pInsertPt(1)

'Debug.Print pBlock.Linetype & "," & pBlock.LinetypeScale & "," & pBlock.Lineweight

'Debug.Print pBlock.XScaleFactor & "," & pBlock.YScaleFactor & "," & pBlock.ZScaleFactor

'Debug.Print

MsgBox "块  名:" & pBlock.Name & Chr(13) & "所在层:" & pBlock.Layer & Chr(13) & "编  码:" & pXDatavlaue(1) & Chr(13) & "坐  标:" & Format(pInsertPt(0), "0.0000") & "," & Format(pInsertPt(1), "0.0000")

ElseIf pEntity.ObjectName = "AcDbPolyline" Then

Set pPolyline = pEntity

pPolyline.GetXData "SOUTH", pXDataType, pXDatavlaue

pCoords = pPolyline.Coordinates

'Debug.Print pXDatavlaue(1) & "," & pPolyline.ObjectID

For j = 0 To UBound(pCoords)

If j Mod 2 = 0 Then

'Debug.Print sCoor

sCoor = ""

End If

sCoor = sCoor & pCoords(j) & ","

Next j

Debug.Print

End If

Next pEntity

pSlct.Delete

'UserForm1.Show

End Sub

AutoCAD开发1---获取块属性的更多相关文章

  1. NX二次开发-UFUN获取块的参数UF_MODL_ask_block_parms

    NX11+VS2013 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> UF_initialize( ...

  2. AutoCAD开发4--添加块)

    Private Sub CommandButton3_Click() Dim pInsertPnt As Variant 'pInsertPnt(0) = 100.5141: pInsertPnt(1 ...

  3. AutoCAD开发2--添加带属性的点

    Private Sub CommandButton11_Click() Dim pPoint As AcadPoint Dim DataType(0 To 1) As Integer Dim Data ...

  4. C#.Net实现AutoCAD块属性提取

    https://blog.csdn.net/dengyiyu/article/details/2201175 本文主要给大家介绍一下SmartSoft中用C#.Net实现AutoCAD块属性提取的方法 ...

  5. C#开发BIMFACE系列18 服务端API之获取模型数据3:获取构件属性

    系列目录     [已更新最新开发文章,点击查看详细] 本篇主要介绍如何获取单文件/模型下单个构建的属性信息. 请求地址:GET https://api.bimface.com/data/v2/fil ...

  6. C#开发BIMFACE系列20 服务端API之获取模型数据5:批量获取构件属性

    系列目录     [已更新最新开发文章,点击查看详细] 在<C#开发BIMFACE系列18 服务端API之获取模型数据3:获取构件属性>中介绍了获取单个文件/模型的单个构建的属性,本篇介绍 ...

  7. Python中如何获取类属性的列表

    这篇文章主要给大家介绍了在Python中如何获取类属性的列表,文中通过示例代码介绍的很详细,相信对大家的学习或者工作具有一定的参考借鉴价值,有需要的朋友可以参考借鉴,下面来一起看看吧. 前言 最近工作 ...

  8. JS中isPrototypeOf 和hasOwnProperty 的区别 ------- js使用in和hasOwnProperty获取对象属性的区别

    JS中isPrototypeOf 和hasOwnProperty 的区别 1.isPrototypeOf isPrototypeOf是用来判断指定对象object1是否存在于另一个对象object2的 ...

  9. js中获取css属性

    直接获取 window.onload = function() { var but = document.getElementById('button'); var div = document.ge ...

随机推荐

  1. Python模块 os和sys

    os模块是与操作系统交互的一个接口 os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相 ...

  2. 执行sql语句为什么?用PreparedStatement要比Statement好用

    PreparedStatement public interface PreparedStatement extends Statement;可以看到PreparedStatement是Stateme ...

  3. 【算法和数据结构】_16_小算法_IntToStr: 将整型数据转换为字符串

    /* IntToStr: 将整型数据转换为字符串 */ #include <stdio.h> void int_to_str(const unsigned long int i_numbe ...

  4. Java同步学习(持续更新)

    在需要考虑线程安全性的场合,可以考虑以下五种方式来实现线程的安全性: 1.同步方法 即有synchronized关键字修饰的方法. 由于java的每个对象都有一个内置锁,当用此关键字修饰方法时,   ...

  5. [蓝桥杯]ALGO-187.算法训练_P0502

    编写一个程序,读入一组整数,这组整数是按照从小到大的顺序排列的,它们的个数N也是由用户输入的,最多不会超过20.然后程序将对这个数组进行统计,把出现次数最多的那个数组元素值打印出来.如果有两个元素值出 ...

  6. centos7 源码安装redis

    安装3.x [root@node1 ~]# yum install wget gcc-c++ make [root@node1 ~]# wget http://download.redis.io/re ...

  7. mysql 拒绝登录解决

    一大早打开Navicat Lite for MySQL客户端,提示1045 access denied for user ’root’@’localhost’ using password yes,太 ...

  8. 构建一个Vue项目

    一 我们需要安装vue.js Vue.js官网 当我们已经安装了vue-cli,那么我们需要更新Vue-cli. vue-cli3.0使用及配置 二 安装好了之后: 我们可以直接使用命令:mkdir ...

  9. 【Linux】【Jenkins】编译过程中遇到ERROR: Failed to parse POMs的解决方案

    自动化构建的时候报错,网搜查询说是maven的jenkinks配置问题导致的.修改系统工具配置的maven配置就可以了 Started by user XX Building in workspace ...

  10. java常见面试题及答案 11-20(JVM)

    11.JVM内存分哪几个区,每个区的作用是什么? Java虚拟机主要分为以下一个区: 方法区:1. 有时候也成为永久代,在该区内很少发生垃圾回收,但是并不代表不发生GC,在这里进行的GC主要是对方法区 ...