Hi,
I am working on a plug-in for Autodesk Inventor in which sketch entities would be translated with geometry and constraints.
Here I am facing problem while applying tangent constraint between arc and bspline entities. Please see the attached snap "InputSketch.jpg".
In this sketch, arc entity is created first. Then bspline is created such that start point of bspline is coincident with center point of arc and end point of bspline is coincident with end point of arc. Then I applied the tangent constraint between arc and bspline.
The same sequence of creating entities and applying constraints is maitained while importing the sketch in Inventor. But while applying tangent constraint, there is issue when I use the ground constraint with arc entity.
Here is the sample code I used:
//===========*********==========
CComPtr<GroundConstraint>groundConstraint;
GeometricConstraints::AddGround(SketchEntity* arc, &groundConstraint);
CComPtr<TangentSketchConstraint>tangentConstraint;
HRESULT hr = GeometricConstraints::AddTangent(SketchEntity* arc, SketchEntity* bspline, CComVariant(), &tangentConstraint);
groundConstraint->Delete();
//===========*********==========
I tried this but it fails to apply tangent constraint. Please see the attached snap "WithUsingGroundConstraint.jpg" and refer "WithUsingGroundConstraint.ipt".
If I avoid to apply ground constriant, it modifies the geometry of sketch. Please see attached snap "WithoutUsingGroundConstraint.jpg" and refer "WithoutUsingGroundConstraint.ipt".
Could any one please tell me, what am I doing wrong? Is it necessary to apply ground constraint in plug in? if not, then why the tangent constraint getting failed?
Thanks in advance!!!!!!!
Hi,
Please find attachment. Hope you could get the zip file this time.
I have written the sample code for the issue with line and arc entity. I was not able to reproduce it for arc and bspline. Here I consider the issue is same in both the cases.
=============Sample code==============
CComPtr<Point2d> pt1 = TransientGeometry::MethodCreatePoint2d(0.1, 0.3);
CComPtr<Point2d> pt2 = TransientGeometry::MethodCreatePoint2d(0.2, 0.2);
CComPtr<Point2d> pt3 = TransientGeometry::MethodCreatePoint2d(0.3, 0.1);
CComPtr<Point2d> pt4 = TransientGeometry::MethodCreatePoint2d(0.6, 0.8);
CComPtr<Point2d> pt5 = TransientGeometry::MethodCreatePoint2d(0.8, 0.6);
CComPtr<SketchPoint> sketchPt1 = SketchPoints::MethodAdd(pt1, FALSE);
CComPtr<SketchPoint> sketchPt2 = SketchPoints::MethodAdd(pt2, FALSE);
CComPtr<SketchPoint> sketchPt3 = SketchPoints::MethodAdd(pt3, FALSE);
CComPtr<SketchPoint> sketchPt4 = SketchPoints::MethodAdd(pt4, FALSE);
CComPtr<SketchPoint> sketchPt5 = SketchPoints::MethodAdd(pt5, FALSE);
CComPtr<SketchLine> sketchLine1 = SketchLines::MethodAddByTwoPoints(sketchPt1, sketchPt4);
CComPtr<SketchLine> sketchLine2 = SketchLines::MethodAddByTwoPoints(sketchPt3, sketchPt5);
CComPtr<SketchLine> sketchLine3 = SketchLines::MethodAddByTwoPoints(sketchPt1, sketchPt3);
sketchLine3->Construction = true;
CComPtr<SketchArc> sketchArc = SketchArcs::MethodAddByCenterStartEndPoint(sketchPt2, sketchPt1, sketchPt3, TRUE);
CComPtr<SketchPoint> arcCenterPt = sketchArc->GetCenterSketchPoint();
sketchPt2->Merge(arcCenterPt);
CComQIPtr<SketchEntity> sketchLine1Entity(sketchLine1);
CComQIPtr<SketchEntity> sketchLine2Entity(sketchLine2);
CComQIPtr<SketchEntity> sketchArcEntity(sketchArc);
CComPtr<TangentSketchConstraint>tangentConstraint1;
CComPtr<TangentSketchConstraint>tangentConstraint2;
GeometricConstraints::AddTangent(sketchArcEntity, sketchLine1Entity, CComVariant(), &tangentConstraint1);
GeometricConstraints::AddTangent(sketchArcEntity, sketchLine2Entity, CComVariant(), &tangentConstraint2);
========================================
In this case tangentConstraint2 fails. If I add ground costraint to the sketchLine2Entity then and then only the tangentConstraint2 gets applied to the arc and tangentConstraint2. But as I am working for the plug in, I don't want to add ground constraint anywhere.
Please let me know why tangentConstraint2 fails and possible solution if any.
Thank you in advance!!!!