Message 1 of 3
Issue with GeometryIntent while Attaching a sketched symbol to an Existing sketched Symbol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I was trying to insert & attach a new sketch symbol to an existing sketch symbol as associative like when I move existing sketch symbol, new symbol has to move accordingly. The below code is creating geometry intent but when I pass the geometry intent as an ObjectCollection for leader points it is failing with error 'Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))'.
Geometry intent while attaching sketch symbol to other entities such as Drawing curve, balloon or dimensions is working fine, but while attaching sketch symbol to an Existing sketch Symbol is failed.
Any help is appreciated.
Inventor.Application oApp = Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;
DrawingDocument drawingDocument = oApp.ActiveDocument as DrawingDocument;
SketchedSymbol existingSketchedSymbol = oApp.CommandManager.Pick(SelectionFilterEnum.kDrawingSketchedSymbolFilter, "Select Existing Symbol to Attach to") as SketchedSymbol;
Point2d existingSymbolPositionPoint = existingSketchedSymbol.Position;
//SketchedSymbolDefinition existingSymbolDefinition = existingSketchedSymbol.Definition;
DrawingSketch sketch = existingSketchedSymbol.Definition.Sketch;
SketchLines AllSketchLines = sketch.SketchLines;
Dictionary<double, SketchLine> Sketchlines = new Dictionary<double, SketchLine>();
foreach (SketchLine sketchLine in AllSketchLines)
{
Sketchlines.Add(sketchLine.Length, sketchLine);
}
double lengthFromSketchDefinition = Sketchlines.OrderByDescending(x => x.Key).ToDictionary(x => x.Key, y => y.Value).First().Key;
Point2d existingSymbolEndpoint = oApp.TransientGeometry.CreatePoint2d(existingSymbolPositionPoint.X - lengthFromSketchDefinition, existingSymbolPositionPoint.Y);
string NameofNewSymbol = "Tail LH";
SketchedSymbolDefinition oSketchedSymbolDeff = drawingDocument.SketchedSymbolDefinitions[NameofNewSymbol];
GeometryIntent geometryIntent = drawingDocument.ActiveSheet.CreateGeometryIntent(existingSketchedSymbol, existingSymbolEndpoint);
ObjectCollection Leaderpoints = oApp.TransientObjects.CreateObjectCollection();
Leaderpoints.Add(existingSymbolEndpoint);
Leaderpoints.Add(geometryIntent);
//Leaderpoints.Add(geometryIntent.PointOnSheet);
SketchedSymbol NewSketchedSymbol = drawingDocument.ActiveSheet.SketchedSymbols.AddWithLeader(oSketchedSymbolDeff, Leaderpoints, 0, 1, null, true, true);
Thanks,
GopinadhGvs.
GopinadhGvs.