M
mzr
Unregistered / Unconfirmed
GUEST, unregistred user!
谁懂delphi向automation变量传递?在传递参数时类型出错。
***-----------------------------------------------------
VBA selectOnScreen函数定义如下:(提示用户在屏幕上拾取的对象并将其添加到活动的选择集中)
object.SelectOnScreen [FilterType][, FilterData]
Object
SelectionSet
The object or objects this method applies to.
FilterType
Integer; input-only; optional
A DXF group code specifying the type of filter to use.
FilterData
Variant; input-only; optional
The value to filter on.
*---------------------------------------------------------------
VBA代码如下:
以下代码指定三个条件:对象必须是蓝色的,必须是 Circle,必须在图层 0 上。代码还将 FilterType 和 FilterData 声明为三个元素的数组,并将每个条件指定给一个元素:
Sub Ch4_FilterBlueCircleOnLayer0()
Dim sstext As AcadSelectionSet
Dim FilterType(2) As Integer
Dim FilterData(2) As Variant
Set sstext = ThisDrawing.SelectionSets.Add("SS4")
FilterType(0) = 0
FilterData(0) = "Circle"
FilterType(1) = 62
FilterData(1) = acBlue
FilterType(2) = 8
FilterData(2) = "0"
sstext.SelectOnScreen FilterType, FilterData
End Sub
转换成Delphi代码:
procedure TForm1.Ch4_FilterBlueCircleOnLayer0;
var
selectSet:OleVariant;
I:integer;
filtertype:array[0..2]of integer;
filterdata:Variant;
begin
for I:=0 to acadDoc.selectionSets.count-1 do //遍历选择集,如果ss4已经存在就不建了。
begin
if acadDoc.selectionSets.Item.name='ss4' then
selectSet:=acadDoc.selectionSets.Item
else
selectSet:=acadDoc.selectionSets.add('ss4');
end;
//创建过滤类型和过滤数据
// filtertype:=vararraycreate([0,2],VT_INT);
filterdata:=vararraycreate([0,2],VT_VARIANT);
filtertype[0]:= 0; filterdata[0]:='circle';//对象类型是圆
filtertype[1]:=62; filterdata[1]:=5;//颜色是蓝色
filtertype[2]:=8; filterdata[2]:='0';//图层为0
{以下代码指定三个条件:对象必须是蓝色的,必须是 Circle,必须在图层 0 上。
代码还将 FilterType 和 FilterData 声明为三个元素的数组,并将每个条件指定
给一个元素:}
selectSet.SelectOnScreen(filtertype,vararrayref(filterdata));
end;
***-----------------------------------------------------
VBA selectOnScreen函数定义如下:(提示用户在屏幕上拾取的对象并将其添加到活动的选择集中)
object.SelectOnScreen [FilterType][, FilterData]
Object
SelectionSet
The object or objects this method applies to.
FilterType
Integer; input-only; optional
A DXF group code specifying the type of filter to use.
FilterData
Variant; input-only; optional
The value to filter on.
*---------------------------------------------------------------
VBA代码如下:
以下代码指定三个条件:对象必须是蓝色的,必须是 Circle,必须在图层 0 上。代码还将 FilterType 和 FilterData 声明为三个元素的数组,并将每个条件指定给一个元素:
Sub Ch4_FilterBlueCircleOnLayer0()
Dim sstext As AcadSelectionSet
Dim FilterType(2) As Integer
Dim FilterData(2) As Variant
Set sstext = ThisDrawing.SelectionSets.Add("SS4")
FilterType(0) = 0
FilterData(0) = "Circle"
FilterType(1) = 62
FilterData(1) = acBlue
FilterType(2) = 8
FilterData(2) = "0"
sstext.SelectOnScreen FilterType, FilterData
End Sub
转换成Delphi代码:
procedure TForm1.Ch4_FilterBlueCircleOnLayer0;
var
selectSet:OleVariant;
I:integer;
filtertype:array[0..2]of integer;
filterdata:Variant;
begin
for I:=0 to acadDoc.selectionSets.count-1 do //遍历选择集,如果ss4已经存在就不建了。
begin
if acadDoc.selectionSets.Item.name='ss4' then
selectSet:=acadDoc.selectionSets.Item
else
selectSet:=acadDoc.selectionSets.add('ss4');
end;
//创建过滤类型和过滤数据
// filtertype:=vararraycreate([0,2],VT_INT);
filterdata:=vararraycreate([0,2],VT_VARIANT);
filtertype[0]:= 0; filterdata[0]:='circle';//对象类型是圆
filtertype[1]:=62; filterdata[1]:=5;//颜色是蓝色
filtertype[2]:=8; filterdata[2]:='0';//图层为0
{以下代码指定三个条件:对象必须是蓝色的,必须是 Circle,必须在图层 0 上。
代码还将 FilterType 和 FilterData 声明为三个元素的数组,并将每个条件指定
给一个元素:}
selectSet.SelectOnScreen(filtertype,vararrayref(filterdata));
end;