AddAngularDimension throws exception

AddAngularDimension throws exception

KarolisCAMax
Participant Participant
112 Views
1 Reply
Message 1 of 2

AddAngularDimension throws exception

KarolisCAMax
Participant
Participant

I am trying to add a simple angular dimension, but I do struggle with parameter passing.

I have tried 2 options:
1. Create GeometryIntent objects which would represent Curve2dLine

I can see that an actual geometry Type is my drawing curves are Curve2dLine, but the value of property IntentType returns:

kPointEnumIntent58113Intent is a PointIntentEnum.

While the value of property Intent returns:

kGeometryIntent58116Intent is a DrawingCurve or a SketchEntity.

 

            var curveSegment = curve.Segments[1];
            var otherCurveSegment = otherCurve.Segments[1];

            var curveIntent = parentLayout.sheet.CreateGeometryIntent(curveSegment, IntentTypeEnum.kGeometryIntent);
            var otherCurveIntent = parentLayout.sheet.CreateGeometryIntent(otherCurveSegment, IntentTypeEnum.kGeometryIntent);


I did try to vary, by leaving second argument of CreateGeometryIntent empty, passing segment.Geometry, but I am still unssuccesful with this approach.

I wish to use this appraoach, it's easier to pass 2 non parallel curve objects, but how shall I do that when CreateGeometryIntent always returns PointIntent. Is it even possible to get LineIntent by using this method?

P.S this should be done for part document so CreateGeometryProxy is not an option I guess..

2. I have tried to pass 3 points instead, I did draw those points onto a sketch and it seems everything is correct and my curves and points are retrieved as expected, but I get same Unspecified Exception when I make a call for AddAngular method.

// 1. Find the shared point between the two curves
Point2d sharedPoint = FindSharedEndpoint(curve1, curve2);
if (sharedPoint == null)
    throw new Exception("Drawing curves do not share a common endpoint.");

// 2. Determine the other endpoints
Point2d otherPoint1 = GetOtherEndpoint(curve1, sharedPoint);
Point2d otherPoint2 = GetOtherEndpoint(curve2, sharedPoint);

// 3. Create GeometryIntents for the three points
GeometryIntent intentShared = parentLayout.sheet.CreateGeometryIntent(sharedPoint, IntentTypeEnum.kPointIntent);
GeometryIntent intent1 = parentLayout.sheet.CreateGeometryIntent(otherPoint1);
GeometryIntent intent2 = parentLayout.sheet.CreateGeometryIntent(otherPoint2);

var tg = parentLayout.m_application.TransientGeometry;
var newPos = tg.CreatePoint2d(intentShared.PointOnSheet.X - 1, intentShared.PointOnSheet.Y - 2);

//DrawingSketch tempSketch = parentLayout.drawingView.Sketches.Add();
DrawingSketch tempSketch = parentLayout.sheet.Sketches.Add();
tempSketch.Edit();
SketchLine tempLine = tempSketch.SketchLines.AddByTwoPoints(sharedPoint, newPos);
SketchLine curveLine = tempSketch.SketchLines.AddByTwoPoints(sharedPoint, otherPoint1);
SketchLine otherLine = tempSketch.SketchLines.AddByTwoPoints(sharedPoint, otherPoint2);
tempSketch.SketchPoints.Add(newPos);

tempSketch.ExitEdit();

// 4. Add angular dimension using 3-point method
//Point2d position = /* your text position here */;
AngularGeneralDimension angDim = genDims.AddAngular(
    newPos,
    intentShared,
    intent1,
    intent2);


Any ideas what's missing?

Thanks in advance


 

0 Likes
Accepted solutions (1)
113 Views
1 Reply
Reply (1)
Message 2 of 2

KarolisCAMax
Participant
Participant
Accepted solution

Finally I managed to make it work 

            var curveIntent = sheet.CreateGeometryIntent(angularCurve);
            var otherCurveIntent = sheet.CreateGeometryIntent(baseCurve);


Where the curves has to be a simple DrawingCurve objects.

Don't know how I missed that, probably position location was incorrect previously.

0 Likes