CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoLISP 开发指南

关于在 AutoLISP 和 ActiveX 数据类型之间进行转换 (AutoLISP/ActiveX)

2023-1-6 01:27| 发布者: admin| 查看: 431| 评论: 0|来自: AutoCAD

摘要: 使用 ActiveX 支持和核心 AutoLISP 函数时,需要在数据类型之间进行转换。

使用 ActiveX 支持和核心 AutoLISP 函数时,需要在数据类型之间进行转换。

注意:AutoLISP 中的 ActiveX 支持仅限于 Windows。

使用 the方法 向图形中添加圆需要指定圆的中心点和半径。这些参数称为中心半径中心被定义为一个变体(三元素的双精度数组),半径被列为双精度数组:AddCircle

(setq RetVal (vla-AddCircle aMSpace Center Radius))

元素

雷瓦尔

对象;仅输出。从方法生成的圆形对象。AddCircle

aMSpace

对象;仅输入。该方法应处理的对象。AddCircle

中心

变体(双精度的三元素数组);仅输入。指定圆中心的 3D WCS 坐标。

变体本质上是可以包含不同类型数据的自定义结构。例如,字符串、整数和数组都可以用变体表示。与数据一起存储的是标识数据类型的信息。此自定义功能使变体可用于将参数传递到 ActiveX 服务器,因为它使基于任何语言的服务器能够理解数据值。

半径

双;仅输入。圆的半径。必须是正数。

AutoLISP 到 ActiveX 数据类型

ActiveX 支持许多与 AutoLISP 中类似的数据类型,但有一些独特的数据类型不直接映射到 AutoLISP 支持的数据类型。转换数据类型的方法如下:

接受的 AutoLISP 数据类型代替 ActiveX 数据类型

整数

真正

字符串

埃纳姆

VLA 对象

变体

列表

:安全阵列

布尔

:VLAX-true

:VLAX-false

:vlax-null

字节

X

布尔

X

X

整数

X

X

单/短

X

X

X

对象

X

字符串

X

变体

X

数组

X

X

Empty

X

Converting Array and List data types

The ActiveX array data type are similar to a list in AutoLISP. They contain multiple elements that represent different data structures. A common use for an array is to represent a coordinate value. You can use to convert an array to a list. Converting a list to an array requires you to define the data type and number of elements the array should have with , and assign the values of the list to the elements of the array using the . vlax-safearray->listvlax-make-safearrayvlax-safearray-fill

Converting Variant data types

Variant data types are used when a method might return or use more than one type of data. You can use to create a variant. When creating a variant, you specify the type of data and value it should hold. If a variant is returned by a method or property, you can use the and functions. vlax-make-variantvlax-variant-typevlax-variant-value

Converting VLA-object, Handles, and Ename data types

There are a number of ways to refer to AutoCAD drawing objects with AutoLISP. These include the following:

VLA-objects

Returned by ActiveX functions. Use to convert from the VLA-object to ename (entity name) data type. vlax-vla-object->ename

(setq MSpace (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))))
#<VLA-OBJECT IAcadModelSpace 0000000030434638>

(setq circObj (vla-AddCircle MSpace (vlax-3d-point '(5.0 5.0 0.0)) 3))
#<VLA-OBJECT IAcadCircle 00000000303b2698>

(vlax-vla-object->ename circObj)
<Entity name: 7ffffb05de0>
Entity names (enames)

Returned by , , and , identifying objects in an open drawing. Use to convert from the ename to VLA-object data type. handententgetentselvlax-ename->vla-object

(setq en (handent handle-circle))
<Entity name: 27f0538>

(setq en (car (entsel "\nSelect circle: ")))
<Entity name: 27f0538>

(vlax-ename->vla-object en)
#<VLA-OBJECT IAcadCircle 00000000303b3718>
处理

通过从实体名称的关联列表中检索 DXF 5 组代码返回,实体在 AutoCAD 会话中保留这些代码。用于返回与句柄关联的 VLA 对象。vla-get-handlevla-handleToObject

(vla-get-handle vla-circle)
"4F"

(setq handle-circle (cdr (assoc 5 (entget ename-circle))))
"4F"

(setq vla-circle (vla-handleToObject acadDocument handle-circle))
#<VLA-OBJECT IAcadCircle 03642c24>
对象标识

由 ActiveX、ObjectARX 和 Manage .NET 程序用于标识对象。用于将对象 ID 转换为 VLA 对象,或用于将 VLA 对象转换为对象 ID。vla-ObjectIDToObject vla-get-ObjectID

(setq objid-Circle (vla-get-objectid vla-circle))
41878840

(vla-ObjectIDtoObject acadDocument objid-circle)
#<VLA-OBJECT IAcadCircle 03642c24>

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部