Drawing annotation between part sketch

Drawing annotation between part sketch

taher.basha
Enthusiast Enthusiast
430 Views
3 Replies
Message 1 of 4

Drawing annotation between part sketch

taher.basha
Enthusiast
Enthusiast

I am trying to annotate between two sketch lines which are Part sketch in Inventor Drawing.

I am getting error at this line "sht.DrawingDimensions.GeneralDimensions.AddLinear(tg.CreatePoint2d(1, 1), int1, int2,DimensionTypeEnum.kAlignedDimensionType);"

 

DrawingDocument dwg = invApp.ActiveDocument as DrawingDocument;
TransientGeometry tg = invApp.TransientGeometry;

Sheet sht = dwg.Sheets["Sheet:1"];

DrawingView dw = sht.DrawingViews.Cast<DrawingView>().Where(dg => dg.Name.Contains("UPPER")).FirstOrDefault();

PartDocument pd = dw.ReferencedDocumentDescriptor.ReferencedDocument;
PlanarSketch psk = pd.ComponentDefinition.Sketches["upper-text1-sketch"];

List<SketchLine> sklns = psk.SketchLines.Cast<SketchLine>().Where(sk => sk.Construction == true).ToList();

LineSegment2d ln1 = sklns[0].Geometry;
LineSegment2d ln2 = sklns[1].Geometry;

GeometryIntent int1 = sht.CreateGeometryIntent(ln1);
GeometryIntent int2 = sht.CreateGeometryIntent(ln2);

sht.DrawingDimensions.GeneralDimensions.AddLinear(tg.CreatePoint2d(1, 1), int1, int2,DimensionTypeEnum.kAlignedDimensionType);

 

Capture.PNG

0 Likes
431 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @taher.basha.  The problem is that you are trying to supply geometry that is currently within the 'context' (3D model space) of the model, to a method within the drawing directly, and that will not work.  You need to get a reference to the drawing view geometry that represents the model geometry, then use those to get GeometryIntent from, then supply that to the dimension creation method.  To get a reference to the drawing geometry that represents the model geometry, you need to use the oDrawingViewGeometryObject = DrawingView.DrawingCurves(oInputModelGeometryObject)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

taher.basha
Enthusiast
Enthusiast
Hi WCrihfield,

Can i get it elaborated please?
0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Sorry, I will try to explain in more detail.  Within your code, after you set the value of your "psk" variable (PlanarSketch), I see that you are creating a 'List' of SketchLines.  I do not know why you are doing that step, but if you are planning on placing a 'linear' dimension between the first two objects in the List, you need to make sure they are parallel with each other first (not perpendicular or angled).  At this point, those first two objects are SketchLine objects, within a PlanarSketch (not a DrawingSketch), within a Part, and not DrawingCurve or DrawingCurveSegment type objects within a DrawingView on the Sheet.  The Sheet.CreateGeometryIntent() method, if you read what is says about what types of objects you can supply as input to that method, it can only accept objects that already exist on the sheet (such as DrawingCurve, SketchEntities that originate from a DrawingSketch, DrawingDimension, Centermark, Centerline).  Those SketchLines from the PlanarSketch in the part can not be used directly in that method.  So, in order to get the DrawingCurve type object that exists within the DrawingView object that you need to use as input to the Sheet.CreateGeometryIntent method, you must create a variable of Type DrawingCurves, and set its value from the DrawingView.DrawingCurves property, and supply that SketchLine object as input into that DrawingCurves property, then it will return the DrawingCurves objects collection which contains the DrawingCurve object you need.  Then supply that DrawingCurve object as input into the CreateGeometryProxy method to get the GeometryIntent object you need ("int1") for one side of your AddLinear() method.  I hope this makes more sense.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes