如何使用 Solidworks VBA/API 创建 "flip offset" 参考平面

How to create a "flip offset" reference plane with Solidworks VBA/API

我正在尝试创建两个与原点等距的平行参考平面。我可以用以下方法创建正平面:

Dim swDoc As SldWorks.ModelDoc2
Dim distance As Double
Dim BoolStatus As Boolean
Dim swLeftFace As SldWorks.RefPlane
Dim swRightFace As SldWorks.RefPlane

BoolStatus = swDoc.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
Set swRightFace = swDoc.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_Distance, distance, 0, 0, 0, 0)

但是,我无法创建负位面。当“距离”为负时,它被评估为 0。这将创建一个与原点重合的平面。 我尝试了一些带有“swRefPlaneReferenceConstraint_OptionFlip”约束的变体,但文档非常差,它要么:

创建平面失败

BoolStatus = swDoc.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
Set swLeftFace = swDoc.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_OptionFlip, distance, 0, 0, 0, 0)

或者创建一个具有正偏移的平面,与第一个参考平面重合。这发生在 X=-1、X=0 和 X=1 时。

BoolStatus = swDoc.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
Set swRightFace = swDoc.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_Distance, distance, 0, 0, 0, 0)
BoolStatus = swDoc.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
Set swLeftFace = swDoc.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_Distance, distance, swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_OptionFlip, X, 0, 0)

选项需要这样添加:

Set swRightFace = swDoc.FeatureManager.InsertRefPlane(swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_Distance + swRefPlaneReferenceConstraints_e.swRefPlaneReferenceConstraint_OptionFlip, distance, 0, 0, 0, 0)