I ported the "loft feature with non-planar section" example code from to c++ that creates some lines which shows the issue.
AddOpen fails in all cases, even when an open section exists. It should work on closed sections according to the documentation, but it fails.
The example from the docs states:
Loft Feature With Non-Planar Section API Sample
' Create a 3d profile to use as the section. Even though this section
' is closed the AddOpen method must be used because it is non-planar.
|
AddClosed works as expected. It is successful when a closed section is present and does not when an open section is present.
HRESULT hr;
// get PartComponentDefinition
CComPtr<PartComponentDefinition> pCompDef;
hr = GetPartDoc()->get_ComponentDefinition(&pCompDef);
if (FAILED(hr))
{
return false;
}
CComPtr<TransientGeometry> oTG = GetTransientGeometry();
CComPtr<Point> oPs[6];
hr = oTG->CreatePoint(-8, 6, 10, &oPs[0]);
hr = oTG->CreatePoint(-8, -6, 10, &oPs[1]);
hr = oTG->CreatePoint(0, -4, 8, &oPs[2]);
hr = oTG->CreatePoint(8, -6, 10, &oPs[3]);
hr = oTG->CreatePoint(8, 6, 10, &oPs[4]);
hr = oTG->CreatePoint(0, 4, 8, &oPs[5]);
CComPtr<WorkPoint> oWPs[6];
hr = pCompDef->WorkPoints->AddFixed(oPs[0], VARIANT_FALSE, &oWPs[0]);
hr = pCompDef->WorkPoints->AddFixed(oPs[1], VARIANT_FALSE, &oWPs[1]);
hr = pCompDef->WorkPoints->AddFixed(oPs[2], VARIANT_FALSE, &oWPs[2]);
hr = pCompDef->WorkPoints->AddFixed(oPs[3], VARIANT_FALSE, &oWPs[3]);
hr = pCompDef->WorkPoints->AddFixed(oPs[4], VARIANT_FALSE, &oWPs[4]);
hr = pCompDef->WorkPoints->AddFixed(oPs[5], VARIANT_FALSE, &oWPs[5]);
CComPtr<Sketch3D> oSketch3d = GetSketch3D(0);
CComPtr<SketchLine3D> oStartLine3d;
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oWPs[0], oWPs[1], VARIANT_TRUE, CComVariant(), &oStartLine3d);
CComPtr<SketchLine3D> oLine3d1;
CComPtr<SketchLine3D> oLine3d2;
CComPtr<SketchLine3D> oLine3d3;
CComPtr<SketchLine3D> oLine3d4;
CComPtr<SketchLine3D> oLine3d5;
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oStartLine3d->EndSketchPoint, oWPs[2], VARIANT_TRUE, CComVariant(), &oLine3d1);
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oLine3d1->EndSketchPoint, oWPs[3], VARIANT_TRUE, CComVariant(), &oLine3d2);
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oLine3d2->EndSketchPoint, oWPs[4], VARIANT_TRUE, CComVariant(), &oLine3d3);
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oLine3d3->EndSketchPoint, oWPs[5], VARIANT_TRUE, CComVariant(), &oLine3d4);
// Comment this line out, then AddOpen and AddClosed will fail
// when uncommented, only AddClosed will work
hr = oSketch3d->SketchLines3D->AddByTwoPoints(oLine3d4->EndSketchPoint, oStartLine3d->StartSketchPoint, TRUE, CComVariant(), &oLine3d5);
CComPtr<Profiles3D> pProfiles0;
hr = GetSketch3D(0)->get_Profiles3D(&pProfiles0);
if (FAILED(hr))
return false;
CComPtr<Profile3D> pProfile0;
hr = pProfiles0->AddOpen(&pProfile0);
if (FAILED(hr))
{
hr = pProfiles0->AddClosed(&pProfile0);
if (FAILED(hr))
{
return false;
}
}