我正在使用 PHP 通过 API 与 SAP2000(结构分析软件)连接。
我收到此行标题中提到的错误,我不知道我做错了什么?
$ret = $SapModel->PointObj->setRestraint("A", $supports);
错误:
PHP Fatal error: Uncaught exception 'com_exception' with message 'Parameter 0: Type mismatch.
Stack trace:
#0 C:\...: variant->setRestraint("A", Array)
#1 (main)
这是来自 SAP2000 API 手册:
VB6程序
函数 SetRestraint(ByVal Name As String, ByRef Value() As Boolean, Optional ByVal ItemType As eItemType = object) 只要
- 参数
姓名
现有点对象或组的名称,具体取决于 ItemType 项的值。
价值
这是一个包含六个约束值的数组。
Value(0) = U1
Value(1) = U2
Value(2) = U3
Value(3) = R1
Value(4) = R2
Value(5) = R3
物品种类
这是 eItemType 枚举中的以下项之一:
Object = 0
Group = 1
SelectedObjects = 2
如果此项为 Object,则对 Name 项指定的点对象进行约束分配。
如果此项为组,则对名称项指定的组中的所有点对象进行约束分配。
如果此项为 SelectedObjects,则对所有选定的点对象进行约束分配,而忽略 Name 项。
我的整个代码:ApplicationStart();
$SapModel=$SapObj->SapModel;
$ret = $SapModel->InitializeNewModel;
$ret = $SapModel->File->NewBlank;
settype($Name, "string");
$ret = $SapModel->PointObj->AddCartesian(0, 0, 0, $Name, "A");
$ret = $SapModel->PointObj->AddCartesian(0, 6, 0, $Name, "B");
$ret = $SapModel->FrameObj->AddByPoint("A", "B", $Name);
$supports = array(
True,
True,
True,
False,
False,
False);
$ret = $SapModel->PointObj->setRestraint("A", $supports);
$ret = $SapModel->PointObj->setRestraint("B", $supports);
?>